PHP ord() Function

Example

Return the ASCII value of "S":

<?php
echo ord("S")."<br>";
echo ord("Shanghai")."<br>";
?>

Run Instance

Definition and Usage

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

Syntax

ord(string)
Parameter Description
string Required. The string from which to obtain the ASCII value.

Technical Details

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