Home > Article > Backend Development > How to convert character a into number in php
php method to convert the character a into a number: 1. Use the boolval() function, the syntax "boolval('a')" can convert the character a into the number 1; 2. Use the ord() function , the syntax "ord('a')" will return the ASCII value of character a in integer form, that is, convert character a into the number 97.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php will change the character a Convert to a number
1. Use the boolval() function
boolval() function to convert the variable into a Boolean type, which has only two The values are true (corresponding to the number 1) and false (corresponding to the number 0).
<?php header('content-type:text/html;charset=utf-8'); $str = 'a'; echo boolval($str); ?>
2. Use the ord() function
## The #ord() function returns the ASCII value of the first character in a string, and can also return the ASCII value of a single character. The return value is an ASCII value in integer form.<?php header('content-type:text/html;charset=utf-8'); $str = 'a'; echo ord($str); ?>Description: ASCII ((American Standard Code for Information Interchange): American Standard Code for Information Interchange) is a set of computer codes based on the Latin alphabet System primarily used to display modern English and other Western European languages. It is the most common information exchange standard and is equivalent to the international standard ISO/IEC 646. ASCII was first published as a standard type in 1967, and was last updated in 1986. So far, a total of 128 characters have been defined.
PHP Video Tutorial"
The above is the detailed content of How to convert character a into number in php. For more information, please follow other related articles on the PHP Chinese website!