How to Return ASCII Value of a Character in PHP?

How to Return ASCII Value of a Character in PHP?

  • PHP
  • 1 min read

Here is an example to how to return an ASCII value of a character in PHP. There is a predefined function ord(), which helps us to return an ASCII value of a character.

Below is an example for displaying the ASCII value of a character 'a':

<html>
<body>
<?php
$a='a';
$b=ord($a);
echo $b;
?>
</body>
</html>

Output: 97

See also: