Ascii code. PHPcode & lt ;? Php/*** convert ASCII to hexadecimal and hexadecimal to ASCII * non-profit organizations or individuals may feel free to reprint them, for commercial purposes, please obtain the author's consent ** // question about converting ASCII to hexadecimal functionas ascii code. Code displayed on the Internet
PHP code
"; Echo" asc: ". $ asc;?>
Utf8 is used for saving,
Question 1: Haha is UTF-8 encoded ?? Why can a function be converted from ascii to hexadecimal. The result is \ xe5 \ x93 \ x88 \ xe5 \ x93 \ x88.
I have checked that the hexadecimal format of Haha's ascii code is 54c8 54c8, which is obviously different.
Cannot understand
------ Solution --------------------
It is not appropriate to use "ascii" here, but "convert to hexadecimal,
The function is actually used to represent the string encoding in hexadecimal format.
So all your questions are justified.
It is also funny to write "not-for-profit organizations or individuals can reprint them with confidence, and ask the author's consent for commercial purposes" on the function head,
Because such a simple code is not original, you can write the same code without looking at it,
Therefore, you certainly do not need to "obtain the author's consent"
Discussion
PHP code
/**
*
* Convert ASCII to hexadecimal and hexadecimal to ASCII
* For non-profit organizations or individuals, please feel free to repost them. for commercial purposes, please obtain the author's consent.
*
*/
// Convert ASCII to hexadecimal
Function asc2hex ($ str ){
Return '\ X'. substr (chunk_split (bin2hex ($ str), 2,' \ X'), 0,-2 );
}
// Convert the hexadecimal format to ......