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

青灯夜游
Release: 2023-04-04 18:02:02
Original
3995 people have browsed it

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);
Copy after login

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"); ?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!