Home > Article > Backend Development > How to convert php characters to ASCII code
How to convert characters to ASCII code in php
In PHP, you can use the ord() function to convert characters is ASCII code.
ord() Definition and Usage
ord() function returns the ASCII value of the first character in the string.
Syntax
ord(string)
Parameters
string Required. The string from which to obtain the ASCII value.
Return value: Returns the ASCII value in integer form.
Example
Return the ASCII value of "h":
<?php echo ord("h")."<br>"; echo ord("hello")."<br>"; ?>
Run result:
104 104
Recommendation: " PHP video tutorial》
The above is the detailed content of How to convert php characters to ASCII code. For more information, please follow other related articles on the PHP Chinese website!