English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP ord() Function Usage and Example

PHP String Character String Function Manual

The ord() function is used to return the ASCII value of the first character in the string.

Syntax

int ord ( string $string )

Definition and Usage

return the ASCII value of the character.

If the string is ASCII, ISO-8859、Windows 1252and similar single-byte encoding, which is equal to the position of the character in the character set encoding table. But please note that this function will not detect the encoding of the string, especially it will not recognize similar UTF-8 or UTF-16 This is the Unicode code point (code point) of the multi-byte character.

Return Value

It returns the ASCII value in integer form.

Parameter

Serial NumberParameter and Description
1

string

This is a character set

Online Example

Try the following example, return the ASCII value of "hi", and the final return value is the ASCII value of the character "h":

<?php
   //The return value is the ASCII value of the character "h"
   echo ord("hi")."<br>";
?>
Test and see‹/›

Output Result

104

PHP String Character String Function Manual