String handling functions

Source: Internet
Author: User
1. String output function

Echo

Print

No echo high efficiency, not recommended

Die ()

Exit and print the string A, you can also die directly

Printf

formatting strings

sprintf

Returns a formatted string

2. Commonly used string formatting functions

LTrim ()

Delete the left blank

RTrim

Delete the blank on the right

Trim

Remove white space on both sides

Str_pad

Fills a string with another string for a specified length

Strtolower

Convert a string to lowercase

Strtopper

Convert a string to uppercase

Ucfirst

Converts the first letter of a string to uppercase

Usword

Converts the first letter of each word in a string to uppercase

Nl2br

Inserts an HTML wrap tag before all new lines in the string

Htmlentities

Entity turns into a label

Htmlspecialchars

Label turns into entity

Stripslashes

Remove backslashes

Strip_taps

Delete a label

Md5

Password encryption

3. String comparison function

strcmp (A, B)

Sort by byte, if a is less than b, a negative number is returned, if a is greater than B, a positive number is returned, and the two equals returns 0.

STRCASECMP ()

Ditto, but not case-sensitive

STRNATCMP ()

Sort by natural number

The above describes the string processing function, including the aspects of the 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.