Wednesday, November 20, 2024
Google search engine
HomeLanguagesPHP mb_ord() Function

PHP mb_ord() Function

The m_ord() is an inbuilt function in PHP that returns the Unicode code point for the specific character.

Syntax:

mb_ord(string $string, ?string $encoding = null): int|false

Parameters: This function has two parameters:

  • string: This is the string input. It must be a valid string.
  • encoding: The encoding parameter specifies the character encoding. In case if omitted or null, then the internal character encoding value will be utilized.

Return value: This function returns the first character Unicode if the function is successfully executed otherwise it will return “false”.

Example 1: The following code demonstrates the mb_ord() function.

PHP




<?php    
$string = '©';
$code_point = mb_ord($string, 'ISO-8859-1');
echo $code_point;    
?>


Output:

194

Example 2: The following code demonstrates the mb_ord() function.

PHP




<?php    
$word = 'Hello';
$code_point = mb_ord($word, 'UTF-8');
      
if ($code_point === 72) {
    echo "The first character in the word is 'H'.";
}
else {
    echo "The first character in the word is not 'H'.";
}    
  
?>


Output:

The first character in the word is 'H'.

Reference: https://www.php.net/manual/en/function.mb-ord.php

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments