Home >>PHP String Functions >PHP ord() Function
PHP ord() function is used to get ASCII value of the first character of the given input string. This function accepts only a character string as a single parameter and as a result it returns the ASCII value of the first character of that character string.
Syntax:-
ord($string);
Parameter | Description |
---|---|
string | This is a required parameter. This parameter contains the given input character string. |
Here is an example of ord() function in PHP:
<html> <body> <?php echo ord("P")."<br>"; echo ord("PHPTPOINT")."<br>"; ?> </body> </html>
Here is another example of ord() function in PHP:
<html> <body> <?php echo ord("PHP")."<br>"; echo ord("HTML")."<br>"; echo ord("Java")."<br>"; echo ord("SQL")."<br>"; echo ord("CSS")."<br>"; ?> </body> </html>