Little PHP skills

Source: Internet
Author: User
PHP tips [to] PHP tips seem to be. most of the time, we use strtolower or strtoupper to compare strings, and then judge whether they are equal. In this case, the conversion is required twice. Most of the time, we are for character set conversion will be like this, for example, to determine whether the parameter passed in UTF-8, the five character writing, but more, such as UTF-8, tips for PHP [go]
Tips for PHP

It seems that most of the time, we use strtolower or strtoupper to compare strings, and then judge whether they are equal. In this case, the conversion is required twice. Most of the time, we are for character set conversion will be like this, such as determining whether the parameter passed in UTF-8, the five character writing, but more, such as UTF-8, Utf-8, what should we do with UTF-8? Strtolower? Strupper? No ..
Strncasecmp ($ a, $ B, $ length ..
If the return value is 0, it is equal. how can we determine?
Strncasecmp ($ str, 'utf-8', 5) = 0. then, the input parameter is utf8. is it convenient?
These functions are not commonly used. I can see that the function is used in yii framework. when processing events and determining whether the first two characters are on, this is the case. I also learned a trick.

Http://www.neatstudio.com/show-1477-1.shtml

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.