PHP Eighth lesson string Splitting common functions _php tutorial

Source: Internet
Author: User
Tags sprintf

PHP Eighth lesson string splitting common functions


Course Outline:


This lesson allows you to perform basic operations on strings.

String Knowledge Points:
1. Introduction to Handling strings
2. Commonly used string output functions
3. Commonly used string formatting functions
4. String comparison function
5. Application of regular expressions in strings
6. Regular expressions used with Per1


1.pathinfo ();//Returns the path information for the domain name

2.parse_url ();
3.parse_str ();//used for splitting parameters


PathInfo ();
 
  ";p Rint_r ($arr); echo"
";? >



Split a domain name into an array
 
  ";p Rint_r ($arr 4); echo"
";? >

The same approach takes
 
  ";p Rint_r ($arr 4); echo"
";? >



Method 3
 
  ";p Rint_r ($arr 3); echo"
";? >





String Knowledge Points:
1. Introduction to Handling strings
2. Commonly used string output functions
3. Commonly used string formatting functions
4. String comparison function
5. Application of regular expressions in strings
6. Regular expressions used with Per1




String functions
Echo
Print
printf (); Direct output
sprintf (); direct return


Connector for string:
. Connect with points
print "AAAAAAAAAA";
printf ("----%s--$s--", $a, $b);
%s string
%d numbers
%f floating point type (%.2f = two digits after decimal point)


sprintf (); No direct output, return a new variable




Commonly used string formatting functions:
1. Remove space and string fill function
1.ltrim (); Remove left space
2.rtrim (); Remove Right space
3.trim (); Remove both spaces
4.str_pad ();//used to fill a space or a custom character for a specified length
5.str_repeat ();//For repeating the preceding characters (for creating an unlimited category menu)
6.strlen ()//Get string length


echo "|". Str_repeat ("-", 5). " BB ";




String Case Conversion function
1.strtoupper ();//convert All to uppercase
2.strtolower ();//convert All to lowercase
3.ucfirst ();//Capitalize First letter
4.ucwords (); Capitalize the first letter of each letter




Other string formatting functions:
1.strlen ();//String length
2.strrev ();//String rollover
3.number_format ();//format session numeric character function
4.MD5//MD5 Encrypted string, 32-bit string
5.str_shuffle (); Random scrambled string, number of digits unchanged



String functions:
String functions associated with HTML:
1.NL2BR (): Convert/N to BR label
2.htmlspecialchars (); Turn entity
' < > & turn into entity
": Represents the Entity
<: Less than number
: Greater than sign
3.addslashes ()//' "" \ in front add \ Reduce damage to the database
4.stripslashes ()//' "" \ Remove the front \
3.strip_tags (); Keep only certain tags, remove the labels you want to remove


Note: It is recommended that you perform three-way control before the database is inserted into the database
1.[b][/b] Convert only limited labels, do label filtering
2.addslashes ();
' "" \ \ \ \ \ \ \ \ \ \ \ \ \ "
3.htmlspecialchars ()
' < > & turn into Entities to prevent the database from being photographed in any fairly fast



http://www.bkjia.com/PHPjc/871182.html www.bkjia.com true http://www.bkjia.com/PHPjc/871182.html techarticle PHP Eighth lesson string Splitting common Functions Course Summary: This lesson enables you to perform basic operations on strings. String knowledge Points: 1. Introduction to String Processing 2. Common string Output ...

  • 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.