PHP ord()Functions
Examples
Returns the ASCII value of "h":
<?php
echo ord("h")."<br>";
echo ord("hello")."<br>";
?>
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 Reference Manual Other Extensions