Talking about PHP source two: About Strlen, Strtolower, Strtoupper, Ord, CHR functions

Source: Internet
Author: User
Tags ord
This article mainly introduces about the PHP source two: About Strlen, Strtolower, Strtoupper, Ord, Chr function, has a certain reference value, now share to everyone, there is a need for friends can refer to

int strlen (String string)
Returns the length of a string
There is no relevant implementation in the standard extension, using Z_strlen, Z_strlen_p, or z_strlen_pp in other extension functions to get the length
String Strtolower (String str)
Turns a string into lowercase, which implements the following code
"Classic Source Code"

Char *php_strtolower (char *s, size_t len) {              unsigned char *c, *e;               c = S;              e = C+len;               while (C < e) {                            *c = ToLower (*c);                            C + +;              }              return s;}

This is a simple program that iterates through the strings and turns each character into lowercase, but this is a standard use of pointers.

String Strtoupper (String string)
Turn a string into uppercase
The code implementation is similar to the above program just to turn the ToLower function into a toupper
string chr (int ascii)
Returns a single character that corresponds to the specified ASCII.
Its essence is to return a string of length 1
"Source Code"

           Temp[0] = (char) z_lval_pp (num);              TEMP[1] = 0;              Retval_stringl (temp, 1, 1);

int ord (String string)
Returns the ASCII value of a character
It is essentially the ASCII value that returns the first character of a string
"Source Code"

Return_long ((unsigned char) z_strval_pp (str) [0]);

The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!

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.