Home >Backend Development >PHP Tutorial >Using ord in php to intercept Chinese strings and solve the problem of garbled characters_PHP tutorial
Below we give two examples, both of which use ord to judge character ascii to avoid the problem of Chinese garbled characters. For the function of this function, we can refer to http://www.bKjia.c0m/phper/php/41030. htm article, which gives a good introduction to the use of this function.
The code is as follows
|
Copy code
|
||||
//a character
$str=(pack("i", "100")); echo $str,"=",strlen($str),"byte n"; getascill($str); //s character short integer 2 bytes $str=(pack("s", "100")); echo $str,"=",strlen($str),"byte n"; getascill($str); //l character long integer 4 bytes $str=(pack("l", "100")); echo $str,"=",strlen($str),"byte n"; getascill($str);
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 empty() function in detail_PHP tutorialNext article:php empty() function in detail_PHP tutorial Related articlesSee more |