PHP ord()Functions

PHP String 参考手册PHP String Reference Manual

Examples

Returns the ASCII value of "h":

<?php
echo ord("h")."<br>";
echo ord("hello")."<br>";
?>

Run example »

Definition and Usage

The ord() function returns the ASCII value of the first character in a string.


Syntax

ord(string)

Parameter Description
string Required. The string to get the ASCII value from.

Technical Details

Return value: Returns the ASCII value as an integer.
PHP Version: 4+


PHP String 参考手册PHP String Reference Manual Other Extensions