Core PHP

String Reformatting Functions

String Reformatting Functions
addcslashes()
string addcslashes(string $sOriginal, string $sEscapeList)
This function returns a string of the characters from $sOriginal with the characters of $sEscapeList with a backslash in front of them.
Argument Description
string $sOriginal This is the string that is to be converted.
string $sEscapeList This is a list of characters that will have slashes in front of them.
addslashes()
string addslashes(string $sOriginal)
This function returns a string of the characters from $sOriginal with slashes before the characters that need to be escaped: ', ", \, and NULL.
Argument Description
string $sOriginal This is the string that is to be converted.
convert_uudecode()
string convert_uudecode(string $sEncoded)
This function returns a string of characters that undo the encoding of convert_uuencode().
Argument Description
string $sEncoded This is the string that is to be unencoded.
convert_uuencode()
string convert_uuencode(string $sOriginal)
This function returns a string of unix to unix encoded printable characters that represent the string $sOriginal, which may have unprintable characters. This encoding is used to protect against the fact that different systems may represent the unprintable character differently. This encoding can be unencoded with convert_uudecode().
Argument Description
string $sOriginal This is the string that is to be converted.
get_html_translation_table()
array get_html_translation_table(int $iTable = HTML_SPECIALCHARS, int $iFlags = ENT_COMPAT | ENT_HTML401, string $sEncoding = "UTF-8")
This function returns the table that is used by htmlspecialchars() or htmlentities() to translate strings.
Argument Description
int $iTable This specifies the table that is to be used to translate characters: HTML_ENTITIES or HTML_SPECIALCHARS.
int $iFlags This set of flag bits specifies particular aspects of the translation table:
  • ENT_COMPAT - Table will contain entities for double-quotes, but not for single-quotes.
  • ENT_QUOTES - Table will contain entities for both double and single quotes.
  • ENT_NOQUOTES - Table will neither contain entities for single quotes nor for double quotes.
  • ENT_HTML401 - Table for HTML 4.01.
  • ENT_XML1 - Table for XML 1.
  • ENT_XHTML - Table for XHTML.
  • ENT_HTML5 - Table for HTML 5.
string $sEncoding This specifies the encoding that is to be used:
  • ISO8859-1 - Western European, Latin-1
  • ISO8859-5 - Little used cyrillic charset (Latin/Cyrillic)
  • ISO8859-15 - Western European, Latin-9Adds the Euro sign, French and Finnish letters missing in Latin-1 (ISO-8859-1)
  • UTF-8 - ASCII compatible multi-byte 8-bit Unicode
  • cp866, ibm866, or 866 - DOS-specific Cyrillic charset
  • cp1251, Windows-1251, win-1251, or 1251 - Windows-specific Cyrillic charset
  • cp1252, Windows-1252, or 1252 - Windows specific charset for Western European
  • KOI8-R, koi8-ru, or koi8r - Russian
  • BIG5 or 950 - Traditional Chinese, mainly used in Taiwan
  • GB2312 or 936 - Simplified Chinese, national standard character set
  • BIG5-HKSCS - Big5 with Ho
  • Shift_JIS, SJIS, SJIS-win, cp932, or 932 - Japanese
  • EUC-JP, EUCJP, or eucJP-win - Japanese
  • MacRoman - Charset that was used by Mac OS
  • "" - An empty string activates the default character set and current locale
html_entity_decode()
string html_entity_decode(string $sOriginal, int $iFlags = ENT_COMPAT | ENT_HTML401, string $sEncoding = "UTF-8")
This function returns the string $sOriginal with its HTML entities decoded according to the table that is used by htmlentities() to translate strings. This function is the opposite of htmlentities().
Argument Description
string $sOriginal This specifies the original string with the entities that are to be trnslated.
int $iFlags This set of flag bits is the same as those given by get_html_translation_table().
string $sEncoding This encoding spcification is the same as the one given by get_html_translation_table().
htmlentities()
string htmlentities(string $sOriginal, int $iFlags = ENT_COMPAT | ENT_HTML401, string $sEncoding = ini_get("default_charset"), bool $bDoubleEncode = true)
This function returns the $sOriginal string with the special characters converted to HTML entites. If the input string is invalid for the specified encoding, an empty string is returned to indicate failure, unless ENT_IGNORE or ENT_SUBSTITUTE is specified.
Argument Description
string $sOriginal This is the string that is to be converted.
int $iFlags This set of flag bits is the same as those given by get_html_translation_table().
string $sEncoding This encoding spcification is the same as the one given by get_html_translation_table().
bool $bDoubleEncode This will not encode entities, if it is set to false.
htmlspecialchars_decode()
string htmlspecialchars_decode(string $sOriginal, int $iFlags = ENT_COMPAT | ENT_HTML401)
This function returns the $sOriginal string with the HTML entites converted to the characters. This is the opposite of htmlspecialchars().
Argument Description
string $sOriginal This is the string that is to be converted.
int $iFlags This set of flag bits is the same as those given by get_html_translation_table().
htmlspecialchars()
string htmlspecialchars(string $sOriginal, int $iFlags = ENT_COMPAT | ENT_HTML401, string $sEncoding = ini_get("default_charset"), bool $bDoubleEncode = true)
This function returns the $sOriginal string with the special characters converted to HTML entites. This function is similar to htmlentities(), excepthat it translates a slightly different set of characters. The specified translations are given by
  • & - &
  • " - ", unless ENT_NOQUOTES is set
  • ' - ' (for ENT_HTML401) or ' (for ENT_XML1, ENT_XHTML or ENT_HTML5), but only when ENT_QUOTES is set
  • < - <
  • > - >
Argument Description
string $sOriginal This is the string that is to be converted.
int $iFlags This set of flag bits is the same as those given by get_html_translation_table().
string $sEncoding This encoding spcification is the same as the one given by get_html_translation_table().
bool $bDoubleEncode This will not encode entities, if it is set to false.
nl2br()
string nl2br(string $sOriginal, bool $bIsXhtml = true)
This function returns the $sOriginal string with html line breaks, either <br> or <br /> depending on the value of $bIsXhtml, before all endline characters: '\r', '\n', '\r\n' and '\n\r'.
Argument Description
string $sOriginal This is the string that is to be converted.
bool $bIsXhtml This determines whether the HTML (<br>) or XHTML (<br />) endlines will be inserted.
quoted_printable_decode()
string quoted_printable_decode(string $sEncoded)
This function returns a string of characters that undo the encoding of quoted_printable_encode().
Argument Description
string $sEncoded This is the string that is to be decoded.
quoted_printable_encode()
string quoted_printable_encode(string $sOriginal)
This function returns a string of quote-printable characters.
Argument Description
string $sOriginal This is the string that is to be converted.
quotemeta()
string quotemeta(string $sOriginal)
This function returns the $sOriginal string with a '\' before each of these characters: . \ + * ? [ ^ ] ( $ ).
Argument Description
string $sOriginal This is a string that will be converted.
strip_tags()
string strip_tags(string $sOriginal, string $sAllowedTags = "")
This function returns the $sOriginal string with the null bytes, HTML tags, and PHP tags removed from it.
Argument Description
string $sOriginal This is a string that will be converted.
string $sAllowedTags This is a string is a set of tags that will not be stripped out.
stripcslashes()
string strip_tags(string $sOriginal)
This function returns the $sOriginal string with backslashes removed from the special characters. It undoes addcslashes().
Argument Description
string $sOriginal This is a string that will be converted.
stripslashes()
string strip_tags(string $sOriginal)
This function returns the $sOriginal string with backslashes removed from the special characters. It undoes addslashes().
Argument Description
string $sOriginal This is a string that will be converted.
 
 

© 2007–2024 XoaX.net LLC. All rights reserved.