PHP String


PHP string processing functions are very powerful, including:

string output

  • echo(): Outputs one or more strings
  • print(): prints a string
  • printf(): output formatted string

string removal

  • trim(): removes special characters or sequences of characters such as leading and trailing blanks
  • ltrim(): removes special characters such as string whitespace, or sequences of specific characters
  • rtrim(): removes special characters such as string trailing blanks or specified character sequences
  • chop(): same as rtrim()

string concatenation

  • implode(): use the characters to combine the contents of the array into a string
  • join(): same as implode()

string segmentation

  • explode(): Split another string with one string
  • str_split(): splits a string into an array

string Get

  • substr(): Get a portion of a string from a string
  • Strstr(): Finds the first occurrence of a string in another string and returns all characters from that position to the end of the string
  • subchr(): same as strstr()
  • strrchr(): Finds the last occurrence of a string in another string and returns all characters from that position to the end of the string

string Substitution

  • Substr_replace(): Replace part of a string with another string
  • str_replace(): replace a string with other characters in a string

string Computation

  • strlen(): Get the length of the string
  • strpos(): Locates the first occurrence of a string
  • strrpos(): Locates the last occurrence of the string

string HTML formatted display

  • nl2br(): Convert newline n to HTML line breaks
  • htmlspecialchars(): Converts some special characters to HTML entities
  • htmlspecialchars_decode(): converts some HTML entities to special characters, the inverse of htmlspecialchars()

string storage(escape)

  • addslashes(): Escape characters are appended to special characters.
  • stripslashes(): The inverse of addslashes().



Copyright 2014-2017 by DeveloperTut.com. All Rights Reserved.
TwitterGoogle+Facebook