Friday, February 6, 2026
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
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32489 POSTS0 COMMENTS
Milvus
126 POSTS0 COMMENTS
Nango Kala
6862 POSTS0 COMMENTS
Nicole Veronica
11983 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12073 POSTS0 COMMENTS
Shaida Kate Naidoo
6995 POSTS0 COMMENTS
Ted Musemwa
7236 POSTS0 COMMENTS
Thapelo Manthata
6946 POSTS0 COMMENTS
Umr Jansen
6930 POSTS0 COMMENTS