How to use ASCII value with PHP

Character encoding is useful in web development for generating character strings from random numbers (CAPTCHA images for instance), displaying non-standard characters and many other purposes.

To use charachter encoding with PHP or To use ASCII value with PHP, we have a function to print ASCII value.

string chr ( int $ascii )

ascii

The ASCII code

Output:

Returns the specified character.

 

For Example:

<?php
$str = "The string ends in escape: ";
$str .= chr(27); /* add an escape character at the end of $str */
/* Often this is more useful */

$str = sprintf(“The string ends in escape: %c”, 27);
?>

For More Info.:-  Click Here

Share This Post

Post Comment