Home>Article>Backend Development> How to return the ASCII value of the first character of a string in PHP

How to return the ASCII value of the first character of a string in PHP

青灯夜游
青灯夜游 Original
2019-01-10 18:00:44 4045browse

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.

How to return the ASCII value of the first character of a string in PHP

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

"; echo ord("PHP")."
"; echo ord("css")."
"; echo ord("CSS"); ?>

Output:

How to return the ASCII value of the first character of a string in PHP

#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!

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