How to filter strings in PHP _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Describes how to filter strings in PHP. We all know the sample code for PHP to filter strings :? Phpnl2br (); ntobraddslashes (); stripslashes (); when operating on the database, escape the special character chop (); we all know the characters except the string on the right.Sample code for PHP to filter strings:

  1. <? Php
  2. Nl2br ();
  3. // N
  4. Addslashes (); stripslashes ();
  5. // Escape special characters for database operations
  6. Chop ();
  7. // Remove spaces on the right of the string
  8. Trim ();
  9. // Remove all spaces in the string
  10. Ltrim ();
  11. // Remove the left space of the string
  12. Htmlspecialchars ();
  13. // Convert '$ ','"','<','>'Is the corresponding html object
  14. Htmlentities ();
  15. // Convert all html tags to corresponding html entities
  16. Array explode (string separator, string str );
  17. // Split the string
  18. String implode (string separator, array arr );
  19. // Connection string
  20. Strtoupper (); strtolower ();
  21. // Converts uppercase and lowercase letters.
  22. Ucfirst ();
  23. // Only converts the first character to uppercase.
  24. Ucwords ();
  25. // Convert the first letter of each word to uppercase.
  26. ?>

We hope that you can gain an in-depth understanding of this knowledge point through the PHP filter string method described in this article.


The following code uses the login PHP code to filter strings :? Php nl2br (); // nto br/addslashes (); stripslashes (); // escape the special character chop () when operating on the database; // remove the character string from the right...

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.