Home >Backend Development >PHP Tutorial >Usage of chr (ascii) and ord (string) functions in php_PHP tutorial
The functions of these two functions are exactly opposite. The chr function returns the character from the specified ASCII value and the ord() function returns the ASCII value of the first character of the string. If you understand this, you will be able to use this function.
Look at the chr function first
chr() function returns characters from the specified ASCII value.
chr(ascii)
ascii argument can be decimal, octal or hexadecimal. Specify octal by leading 0, specify hexadecimal by leading 0x
Example
The code is as follows | Copy code | ||||||||||||||||||||||||
?>Output: 4 *R Isn’t it amazing? In fact, it’s not surprising that I often use chr to operate some invisible codes, such as Think about this What will be output? The result is
Let’s look at the ord function
Statement: The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn Previous article:PHP Chinese character conversion pinyin implementation program_PHP tutorialNext article:PHP Chinese character conversion pinyin implementation program_PHP tutorial Related articlesSee more |