Home >Backend Development >PHP Problem >How to convert php ascii code
php ASCII code conversion method: 1. Use the chr function to return characters from the specified ASCII value; 2. Use the ord function to return the ASCII value of the first character in the string.
Recommended: "PHP Video Tutorial"
PHP Conversion between ASCII codes and characters
ASCII code conversion character:
<?php $i = 65; $ch = chr($i); var_dump($ch); ?> string 'A' (length=1)
chr() function returns characters from the specified ASCII value.
ASCII values can be specified as decimal, octal, or hexadecimal values. Octal values are defined with leading 0, and hexadecimal values are defined with leading 0x.
Character conversion to ASCII code:
<?php $ch = 'A'; $i = ord($ch); var_dump($i); ?> int 65
ord() function returns the ASCII value of the first character in the string.
The above is the detailed content of How to convert php ascii code. For more information, please follow other related articles on the PHP Chinese website!