How to use php chr function?

藏色散人
Release: 2023-02-22 22:22:01
Original
2672 people have browsed it

php chr function is used to return characters from the specified ASCII value. The syntax is chr(ascii), the parameter ascii is required and refers to the ASCII value. ASCII values can be specified as decimal, octal, or hexadecimal values.

How to use php chr function?

#How to use php chr function?

Definition and Usage

The chr() function returns the character from the specified ASCII value.

ASCII values can be specified as decimal, octal, or hexadecimal values. Octal values are defined with leading 0, and hexadecimal values are defined with leading 0x.

Syntax

chr(ascii)
Copy after login

Parameters

ascii required. ASCII value.

Return value: Returns the specified character.

PHP Version: 4

Example 1

Use the octal value 046 to add the ASCII character: &.

Copy after login

Output:

You & me forever!
Copy after login

Example 2

Use decimal values 43 and 61 to add ASCII characters: and =.

Copy after login

Output:

2 + 2 = 4
Copy after login

Example 3

Returning characters from different ASCII values:

"; // 十进制 echo chr(061) . "
"; // 八进制值 echo chr(0x61) . "
"; // 十六进制值 ?>
Copy after login

Output:

= 1 a
Copy after login

The above is the detailed content of How to use php chr function?. 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
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!