The functions of these two functions are exactly the opposite of the CHR function, which returns characters from the specified ASCII value and the Ord () function returns the ASCII value of the first character of the string. Understand that this function is useful for everyone.
See the Chr function First
The CHR () function returns characters from the specified ASCII value.
Chr (ASCII)
The ASCII parameter can be in decimal, octal, or hexadecimal. The octal system is specified by the pre-set, and the hexadecimal is specified by the front 0x
Example
The code is as follows |
Copy Code |
Echo Chr (52); Echo Chr (052); echo Chr (0x52); ?> output: 4 * R |
is not very magical, in fact, it is not my fault that I often do not see the code with CHR to operate as
The code is as follows |
Copy Code |
Echo Chr (13); Echo Chr (32); ?>
|
Let's figure out what this will do, and the result is
A carriage return, a space
Let's look at the Ord function .
The Ord () function returns the ASCII value of the first character of a string.
From above, it's just the opposite of Chr.
Grammar
The code is as follows |
Copy Code |
Ord (String) Example Echo Ord ("H"); echo ord ("Hello"); ?> Output Result: 104 104 |
Okay, now let's look at a comprehensive example
The code is as follows |
Copy Code |
$str 1=CHR (88); echo $str 1; The return value is X $str 2=CHR (Ord (X) +1); // echo $str 2; The return value is Y echo "T"; $str 3=ord (' S '); echo $str 3; The return value is 83 ?> |
Here is an article about the PHP Ord function and Chinese garbled solution
For more detailed information, please see: http://www.bKjia.c0m/phper/php-function/php-ord.htm
http://www.bkjia.com/PHPjc/631668.html www.bkjia.com true http://www.bkjia.com/PHPjc/631668.html techarticle The functions of these two functions are exactly the opposite of the CHR function, which returns characters from the specified ASCII value and the Ord () function returns the ASCII value of the first character of the string. Understand that this function is useful for everyone. ...