Hướng dẫn dùng decimal ascii trong PHP
❮ PHP String Reference Show
Nội dung chính
ExampleReturn the ASCII value of "h": echo ord("h")." Try it Yourself » Definition and UsageThe ord() function returns the ASCII value of the first character of a string. SyntaxParameter Values
Technical Details
❮ PHP String Reference ❮ PHP String Reference ExampleReturn characters from different ASCII values: echo chr(52) . " Try it Yourself » Definition and UsageThe chr() function returns a character from the specified ASCII value. The ASCII value can be specified in decimal, octal, or hex values. Octal values are defined by a leading 0, while hex values are defined by a leading 0x. SyntaxParameter Values
Technical Details
More ExamplesExampleUsing the octal value 046 to add the ASCII Character: &. $str = chr(046); Try it Yourself » ExampleUsing the decimal values 43 and 61 to add the ASCII Characters: + and =. $str = chr(43); Try it Yourself » ❮ PHP String Reference PHP – Get ASCII Value of a CharacterTo get the ASCII value of a character in PHP, call
ExamplesGet ASCII Value of a CharacterIn the following example, we get the ASCII value of character m using
PHP Program Output ConclusionIn this PHP Tutorial, we learned how to convert array into a CSV string, using (PHP 4, PHP 5, PHP 7, PHP 8) ord — Convert the first byte of a string to a value between 0 and 255 Descriptionord(string If the string is in a single-byte encoding, such as ASCII, ISO-8859, or Windows 1252, this is equivalent to returning the position of a character in the character set's mapping table. However, note that this function is not aware of any string encoding, and in particular will never identify a Unicode code point in a multi-byte encoding such as UTF-8 or UTF-16. This function complements chr(). Parameterscharacter A character. Return ValuesAn integer between 0 and 255. ExamplesExample #1 ord() example
Example #2 Examining the individual bytes of a UTF-8 string
The above example will output: Byte 0 of $str has value 240 See Also
arglanir+phpnet at gmail dot com ¶ 10 years ago
rowan dot collins at cwtdigital dot com ¶ 9 years ago
paco at olecode dot com ¶ 2 years ago
v0rbiz at yahoo dot com ¶ 18 years ago
Noname ¶ 8 months ago
Anonymous ¶ 1 year ago
Is CHR () and Ord () is opposite function in PHP?Description. The chr() function generates a character from the specified ASCII value. This function is the inverse of the ord() function which does the opposite of what this function does. What is the return of Ord () function in PHP?The ord() function returns the ASCII value of the first character of a string. What is ASCII value of A to Z?The ASCII value of the lowercase alphabet is from 97 to 122. And, the ASCII value of the uppercase alphabet is from 65 to 90. If the ASCII value of the character entered by the user lies in the range of 97 to 122 or from 65 to 90, that number is an alphabet. What is the CHR function?Chr ( charcode ) The required charcode argument is a Long that identifies a character. Remarks. Numbers from 0 – 31 are the same as standard, nonprintable ASCII codes. For example, Chr(10) returns a linefeed character. |