Computer >> Computer tutorials >  >> Programming >> PHP

ord() function in PHP


The ord() function returns ASCII value of a character.

Syntax

ord(str)

Parameters

  • str  − The string to get an ASCII value from.

Return

The ord() function returns an integer between 0 and 255 that would be the ASCII value of the first character of a string.

Example

The following is an example that returns the ASCII value of the first character of a string −

<?php
   echo ord("welcome");
?>

Output

119