How to score in Word PHP CHR and Ord function implement character subtraction operation implementation code

Source: Internet
Author: User
Tags ord
The CHR function is used to convert an ASCII code to a character
The ORD function is used to convert characters to ASCII code
ASCII code is the computer can display the character encoding, its value range is 0-255, including punctuation, letters, numbers, Chinese characters and so on. In the programming process, the specified characters are often converted to ASCII code for comparison.
The following is a function that PHP provides to convert ASCII codes and characters.
1. Chr () function
This function is used to convert ASCII code values into strings. Its function is declared as follows:
string chr (int ascii);
2. Ord () function
This function is used to convert a string to an ASCII code value. Its function is declared as follows:
int ord (string str);
Example:
Use the Chr () function and the Ord () function to perform the conversion between the string and the ASCII code as follows:

Copy the Code code as follows:


$str 1=CHR (88);
echo $str 1; The return value is X
$str 2=CHR (Ord (X) +1); //
echo $str 2; The return value is Y
echo "\ T";
$str 3=ord (' S ');
echo $str 3; The return value is 83
?>


Run Result: X Y 83

The above describes how Word scores PHP's CHR and Ord function to implement the character subtraction operation implementation code, including the word how to score content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.