Empty string exception hint string common function

Source: Internet
Author: User
Tags chop rfc
Specify character list characters to escape all characters contained in the list
Addcslashes (String $str, string $charlist);

Output: \f\o\o\[\]
Escapes all characters of the string foo[] ASCII code between a-Z
Note: A-Z cannot be written z-a ASCII code must be small to large
echo addcslashes (' foo[') ', ' Z '. A ');
Output: \zoo[' \. ']
To remove backslashes from a string
Stripcslashes
$STR = << <>
\\\\
EOF;
Echo $STR;
//
echo stripcslashes ($STR);
/four escape character escapes to 1/

Escape by getting the value of php.ini magic_quotes_sybase
Addslashes (String $str)
Magic_quotes_sybase = Off
$str = ' \ ' "\ ';
echo addslashes ($STR);
Magic_quotes_sybase = On
$str = ' \ ' "\ ';
echo addslashes ($STR);
"'" \test.php?name= ' Liukai 'if (!GET_MAGIC_QUOTES_GPC ()) {//detect PHP. INI is turned on the Get post cookie automatically escapes the GPC get post Cookie's indent ($_get as & $val) { $val = addslashes ( $val); Automatically go to the Get array }}
  
//Remove the escape character added by the addslashes-manipulated string based on the value of the current Magic_quotes_runtime
Stripaddslashes (String $str)
Magic_quotes_sybase = on
$str = "";
echo stripaddslashes ($STR);
Output '
Magic_quotes_sybase = Off
$str = ' \ ' \ ' \ \ ';
echo stripaddslashes ($STR); The alias function for the
output ' \
//rtrim removes all characters in the specified list of characters to the right of the character list by default, only spaces
Chop (String $str [, String $charlist])
Var_ Dump (Chop (' 123 '));
Output String (4) 123
Var_dump (' 123 c ', ' C ');
Output string (5) 123
Var_dump (' 123 ASW ', ' swa ');
Output string (5) 123


//Returns the specified character of the ASCII code
chr (int $ascii)
Echo chr;
Output a

//Use this function to split a string into small chunks is useful. For example, convert the output of Base64_encode () to a string that conforms to RFC 2045 semantics. It inserts end (the default is "\ r \ n") behind every Chunklen (default 76) character. This function returns a new string without modifying the original string.
Chunk_split (String $body, [, int $chunklen [, string $end ]])
$new _string = Chunk_split (Base64_encode ($data));  Converts the output of Base64_encode () to a string that conforms to RFC 2045 semantics.
Returns information about the characters used in the string
Counts the number of occurrences of each byte value (0..255) in a string and returns the result using multiple modes. Optional parameter mode The default value is 0. The following different results are returned according to the different Mode,count_chars ():
0-An array of values as the number of occurrences of each byte value as the key name.
1-Same as 0, but only byte values with occurrences greater than 0 are listed.
2-Same as 0, but only byte values with occurrences equal to zero are listed.
3-Returns a string consisting of all used byte values.
4-Returns a string consisting of all unused byte values.
Count_chars (String $str [, int $mode])

The above describes the empty string exception hint string commonly used functions, including the empty string exception hint content, I hope 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.