PHP 4, PHP 5, PHP 7, PHP 8
ord - Convert the first byte of a string to a value between 0 and 255

ord( string$character ): int

Interprets the binary value of the first byte of character as an unsigned integer between 0 and 255.

If the string is in a single-byte encoding, such as ASCII, ISO-8859, or Windows 1252, this is equivalent to returning the position of a character in the character set's mapping table. However, note that this function is not aware of any string encoding, and in particular will never identify a Unicode code point in a multi-byte encoding such as UTF-8 or UTF-16.

This function complements chr.



A character.

Return Values

An integer between 0 and 255.

Related Functions

Example of ord

Show all examples for ord

PHP Version:

Function ord:

Strings Functions

Most used PHP functions