Home > Article > Backend Development > How to return the ASCII value of the first character of a string in PHP
In PHP, you can use the built-in function ord(), which can return the ASCII value of the first character of the string. The following article will show you how to use the ord() function. I hope it will be helpful to you.
A brief introduction to the ord() function
The ord() function takes a string as a parameter , and returns the ASCII value of the first character of this string.
Basic syntax:
ord($string);
Return value: It will return an integer value that represents the string passed as a parameter to this function The ASCII value of the first character in .
Simple example of ord() function
The following is an example of how to use the ord() function
<?php echo ord("php")."<br>"; echo ord("PHP")."<br>"; echo ord("css")."<br>"; echo ord("CSS"); ?>
Output:
#The above is the entire content of this article, I hope it will be helpful to everyone's learning. For more exciting content, you can pay attention to the relevant tutorial columns of the PHP Chinese website! ! !
The above is the detailed content of How to return the ASCII value of the first character of a string in PHP. For more information, please follow other related articles on the PHP Chinese website!