Facebook Page Twitter Page LinkedIn Page
× PHP Tutorial PHP Advanced PHP Resources


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

Syntax

ord(string)

Parameters

string Required. Specify the string to get the ASCII value of first character of the string.

Return Value

Returns the ASCII value of the first character of the specified string.

Example:

In the below example, ord() function to used to return the ASCII value of the first character of the string called MyString.

<?php
  $MyString = "Apple";

  echo ord($MyString)."\n";
?>

The output of the above code will be:

65

❮ PHP String functions