diff --git a/reference/strings/functions/htmlspecialchars.xml b/reference/strings/functions/htmlspecialchars.xml index 4edc6b5396..5a9e5cbe90 100644 --- a/reference/strings/functions/htmlspecialchars.xml +++ b/reference/strings/functions/htmlspecialchars.xml @@ -1,110 +1,202 @@ - - - - - - htmlspecialchars - - Convert special characters to HTML entities - - - - Description - - stringhtmlspecialchars - stringstring - intquote_style - stringcharset - booldouble_encode - - - Certain characters have special significance in HTML, and should - be represented by HTML entities if they are to preserve their - meanings. This function returns a string with some of these - conversions made; the translations made are those most - useful for everyday web programming. If you require all HTML - character entities to be translated, use - htmlentities instead. - - - This function is useful in preventing user-supplied text from - containing HTML markup, such as in a message board or guest book - application. The optional second argument, quote_style, tells - the function what to do with single and double quote characters. - The default mode, ENT_COMPAT, is the backwards compatible mode - which only translates the double-quote character and leaves the - single-quote untranslated. If ENT_QUOTES is set, both single and - double quotes are translated and if ENT_NOQUOTES is set neither - single nor double quotes are translated. - - - The translations performed are: - - - - '&' (ampersand) becomes '&amp;' - - - - - '"' (double quote) becomes '&quot;' when ENT_NOQUOTES - is not set. - - - - - ''' (single quote) becomes '&#039;' only when - ENT_QUOTES is set. - - - - - '<' (less than) becomes '&lt;' - - - - - '>' (greater than) becomes '&gt;' - - - - - <function>htmlspecialchars</function> example - + + + + + htmlspecialchars + Convert special characters to HTML entities + + + + Description + + stringhtmlspecialchars + stringstring + intquote_style + stringcharset + booldouble_encode + + + Certain characters have special significance in HTML, and should + be represented by HTML entities if they are to preserve their + meanings. This function returns a string with some of these + conversions made; the translations made are those most + useful for everyday web programming. If you require all HTML + character entities to be translated, use + htmlentities instead. + + + This function is useful in preventing user-supplied text from + containing HTML markup, such as in a message board or guest book + application. + + + The translations performed are: + + + + '&' (ampersand) becomes '&amp;' + + + + + '"' (double quote) becomes '&quot;' when ENT_NOQUOTES + is not set. + + + + + ''' (single quote) becomes '&#039;' only when + ENT_QUOTES is set. + + + + + '<' (less than) becomes '&lt;' + + + + + '>' (greater than) becomes '&gt;' + + + + + + + + &reftitle.parameters; + + + + string + + + The string being converted. + + + + + quote_style + + + The optional second argument, quote_style, tells + the function what to do with single and double quote characters. + The default mode, ENT_COMPAT, is the backwards compatible mode + which only translates the double-quote character and leaves the + single-quote untranslated. If ENT_QUOTES is set, both single and + double quotes are translated and if ENT_NOQUOTES is set neither + single nor double quotes are translated. + + + + + charset + + + Defines character set used in conversion. + The default character set is ISO-8859-1. + + &reference.strings.charsets; + + + + double_encode + + + When double_encode is turned off PHP will not + encode existing html entities, the default is to convert everything. + + + + + + + + + &reftitle.returnvalues; + + The converted string. + + + + + &reftitle.changelog; + + + + + + &Version; + &Description; + + + + + 5.2.3 + + The double_encode parameter was added. + + + + 4.1.0 + + The charset parameter was added. + + + + 4.0.3 + + The quote_style parameter was added. + + + + + + + + + + &reftitle.examples; + + + <function>htmlspecialchars</function> example + Test", ENT_QUOTES); echo $new; // <a href='test'>Test</a> ?> ]]> - - - - - Note that this function does not translate anything beyond what - is listed above. For full entity translation, see - htmlentities. Support for the optional - second argument was added in PHP 3.0.17 and PHP 4.0.3. - - - The third argument charset defines character set - used in conversion. The default character set is ISO-8859-1. Support for - this third argument was added in PHP 4.1.0. - - &reference.strings.charsets; - - When double_encode is turned off PHP will not - encode existing html entities, the default is to convert everything. - This parameter was added in PHP 5.2.3. - - - See also get_html_translation_table, - htmlspecialchars_decode, - strip_tags, - htmlentities, and nl2br. - - - + + + + + + + &reftitle.notes; + + + Note that this function does not translate anything beyond what + is listed above. For full entity translation, see + htmlentities. + + + + + + &reftitle.seealso; + + + get_html_translation_table + htmlspecialchars_decode + strip_tags + htmlentities + nl2br + + + + + - - - - levenshtein - - Calculate Levenshtein distance between two strings - - - - Description - - intlevenshtein - stringstr1 - stringstr2 - intcost_ins - intcost_rep - intcost_del - - - - This function returns the Levenshtein-Distance between the - two argument strings or -1, if one of the argument strings - is longer than the limit of 255 characters. - - - The Levenshtein distance is defined as the minimal number of - characters you have to replace, insert or delete to transform - str1 into str2. - The complexity of the algorithm is O(m*n), - where n and m are the - length of str1 and - str2 (rather good when compared to - similar_text, which is O(max(n,m)**3), - but still expensive). - - - In its simplest form the function will take only the two - strings as parameter and will calculate just the number of - insert, replace and delete operations needed to transform - str1 into str2. - - - A second variant will take three additional parameters that - define the cost of insert, replace and delete operations. This - is more general and adaptive than variant one, but not as - efficient. - - - - - <function>levenshtein</function> example - + + + + + levenshtein + Calculate Levenshtein distance between two strings + + + + &reftitle.description; + + intlevenshtein + stringstr1 + stringstr2 + intcost_ins + intcost_rep + intcost_del + + + The Levenshtein distance is defined as the minimal number of + characters you have to replace, insert or delete to transform + str1 into str2. + The complexity of the algorithm is O(m*n), + where n and m are the + length of str1 and + str2 (rather good when compared to + similar_text, which is O(max(n,m)**3), + but still expensive). + + + In its simplest form the function will take only the two + strings as parameter and will calculate just the number of + insert, replace and delete operations needed to transform + str1 into str2. + + + A second variant will take three additional parameters that + define the cost of insert, replace and delete operations. This + is more general and adaptive than variant one, but not as + efficient. + + + + + &reftitle.parameters; + + + + str1 + + + One of the strings being evaluated for Levenshtein distance. + + + + + str2 + + + One of the strings being evaluated for Levenshtein distance. + + + + + cost_ins + + + Defines the cost of insertion. + + + + + cost_rep + + + Defines the cost of replacement. + + + + + cost_del + + + Defines the cost of deletion. + + + + + + + + + &reftitle.returnvalues; + + This function returns the Levenshtein-Distance between the + two argument strings or -1, if one of the argument strings + is longer than the limit of 255 characters. + + + + + &reftitle.examples; + + + <function>levenshtein</function> example + ]]> - - &example.outputs; - + + &example.outputs; + - - - - - See also soundex, - similar_text, and - metaphone. - - - + + + + + + + &reftitle.seealso; + + + soundex + similar_text + metaphone + + + + + - - - - number_format - Format a number with grouped thousands - - - Description - - stringnumber_format - floatnumber - intdecimals - stringdec_point - stringthousands_sep - - - number_format returns a formatted version of - number. This function accepts either one, - two or four parameters (not three): - - If only one parameter is given, - number will be formatted without decimals, - but with a comma (",") between every group of thousands. - - - If two parameters are given, number will - be formatted with decimals decimals with a - dot (".") in front, and a comma (",") between every group of - thousands. - - - If all four parameters are given, number - will be formatted with decimals decimals, - dec_point instead of a dot (".") before - the decimals and thousands_sep instead of - a comma (",") between every group of thousands. - - - Only the first character of thousands_sep - is used. For example, if you use bar as - thousands_sep on the number - 1000, number_format will - return 1b000. - - - - <function>number_format</function> Example + + + + + number_format + Format a number with grouped thousands + + + + &reftitle.description; + + stringnumber_format + floatnumber + intdecimals + stringdec_point + stringthousands_sep + + + number_format returns a formatted version of + number. This function accepts either one, + two or four parameters (not three): + + If only one parameter is given, + number will be formatted without decimals, + but with a comma (",") between every group of thousands. + + + If two parameters are given, number will + be formatted with decimals decimals with a + dot (".") in front, and a comma (",") between every group of + thousands. + + + If all four parameters are given, number + will be formatted with decimals decimals, + dec_point instead of a dot (".") before + the decimals and thousands_sep instead of + a comma (",") between every group of thousands. + + + + + &reftitle.parameters; + + + + number + - For instance, French notation usually use two decimals, - comma (',') as decimal separator, and space (' ') as - thousand separator. This is achieved with this line : + The number being formatted. - + + + + decimals + + + Sets the number of decimal points. + + + + + dec_point + + + Sets the separator for the decimal point. + + + + + thousands_sep + + + Sets the thousands separator. + + + Only the first character of thousands_sep + is used. For example, if you use bar as + thousands_sep on the number + 1000, number_format will + return 1b000. + + + + + + + + + &reftitle.examples; + + + <function>number_format</function> Example + + For instance, French notation usually use two decimals, + comma (',') as decimal separator, and space (' ') as + thousand separator. This is achieved with this line : + + ]]> - - - - - See also: money_format, sprintf, - printf and sscanf. - - - + + + + + + &reftitle.seealso; + + + money_format + sprintf + printf + sscanf + + + + + - - - - sscanf - - Parses input from a string according to a format - - - - Description - - mixedsscanf - stringstr - stringformat - mixed... - - - The function sscanf is the input analog of - printf. sscanf reads - from the string str and interprets it - according to the specified format, which is - described in the documentation for sprintf. If only - two parameters were passed to this function, the values parsed - will be returned as an array. Otherwise, if optional parameters are passed, - the function will return the number of assigned values. The optional - parameters must be passed by reference. - - - Any whitespace in the format string matches any whitespace in the input - string. This means that even a tab \t in the format string can match a - single space character in the input string. - - - - <function>sscanf</function> Example - + + + + + sscanf + Parses input from a string according to a format + + + + &reftitle.description; + + mixedsscanf + stringstr + stringformat + mixed... + + + The function sscanf is the input analog of + printf. sscanf reads + from the string str and interprets it + according to the specified format, which is + described in the documentation for sprintf. + + + Any whitespace in the format string matches any whitespace in the input + string. This means that even a tab \t in the format string can match a + single space character in the input string. + + + + + &reftitle.parameters; + + + + str + + + The input string being parsed. + + + + + format + + + The interpreted format for str, which is + described in the documentation for sprintf. + + + + + ... + + + Optionally pass in variables by reference that will contain the parsed values. + + + + + + + + + &reftitle.returnvalues; + + If only + two parameters were passed to this function, the values parsed + will be returned as an array. Otherwise, if optional parameters are passed, + the function will return the number of assigned values. The optional + parameters must be passed by reference. + + + + + &reftitle.examples; + + + <function>sscanf</function> Example + ]]> - - - If optional parameters are passed, the function will return the - number of assigned values. - - <function>sscanf</function> - using optional parameters - + + + + + If optional parameters are passed, the function will return the + number of assigned values. + + + + <function>sscanf</function> - using optional parameters + \n"; ?> ]]> - - - - - See also fscanf, printf, - and sprintf. - - - + + + + + + + &reftitle.seealso; + + + fscanf + printf + sprintf + + + + + - - - - strtok - Tokenize string - - - Description - - stringstrtok - stringstr - stringtoken - - - strtok splits a string (str) - into smaller strings (tokens), with each token being delimited by any - character from token. - That is, if you have a string like "This is an example string" you - could tokenize this string into its individual words by using the - space character as the token. - - <function>strtok</function> example - + + + + + strtok + Tokenize string + + + + &reftitle.description; + + stringstrtok + stringstr + stringtoken + + + strtok splits a string (str) + into smaller strings (tokens), with each token being delimited by any + character from token. + That is, if you have a string like "This is an example string" you + could tokenize this string into its individual words by using the + space character as the token. + + + Note that only the first call to strtok uses the string argument. + Every subsequent call to strtok only needs the token to use, as + it keeps track of where it is in the current string. To start + over, or to tokenize a new string you simply call strtok with the + string argument again to initialize it. Note that you may put + multiple tokens in the token parameter. The string will be + tokenized when any one of the characters in the argument are + found. + + + + + &reftitle.parameters; + + + + str + + + The string being split up into smaller strings (tokens). + + + + + token + + + The delimiter used when splitting up str. + + + + + + + + + &reftitle.returnvalues; + + A string token. + + + + + &reftitle.examples; + + + <function>strtok</function> example + ]]> - - - - - Note that only the first call to strtok uses the string argument. - Every subsequent call to strtok only needs the token to use, as - it keeps track of where it is in the current string. To start - over, or to tokenize a new string you simply call strtok with the - string argument again to initialize it. Note that you may put - multiple tokens in the token parameter. The string will be - tokenized when any one of the characters in the argument are - found. - - - The behavior when an empty part was found changed with PHP 4.1.0. The old - behavior returned an empty string, while the new, correct, behavior - simply skips the part of the string: - - Old <function>strtok</function> behavior - + + + + + The behavior when an empty part was found changed with PHP 4.1.0. The old + behavior returned an empty string, while the new, correct, behavior + simply skips the part of the string: + + + + Old <function>strtok</function> behavior + ]]> - - - Output: - - + + &example.outputs; + - - - - New <function>strtok</function> behavior - + + + + New <function>strtok</function> behavior + ]]> - - - Output: - - + + &example.outputs; + - - - - &return.falseproblem; - - See also split and - explode. - - - + + + + + + + &reftitle.notes; + + &return.falseproblem; + + + + &reftitle.seealso; + + + split + explode + + + + + - - - - strtr - Translate certain characters - - - Description - - stringstrtr - stringstr - stringfrom - stringto - - - stringstrtr - stringstr - arrayreplace_pairs - - - This function returns a copy of str, - translating all occurrences of each character in - from to the corresponding character in - to. - - - If from and to are - different lengths, the extra characters in the longer of the two - are ignored. - - <function>strtr</function> example - + + + + strtr + Translate certain characters + + + + &reftitle.description; + + stringstrtr + stringstr + stringfrom + stringto + + + stringstrtr + stringstr + arrayreplace_pairs + + + This function returns a copy of str, + translating all occurrences of each character in + from to the corresponding character in + to. + + + If from and to are + different lengths, the extra characters in the longer of the two + are ignored. + + + + + &reftitle.parameters; + + + + str + + + The string being translated. + + + + + from + + + The string being translated to to. + + + + + to + + + The string replacing from. + + + + + replace_pairs + + + The replace_pairs parameter may be used as a substitute for + to and from in which case it's an + array in the form array('from' => 'to', ...). + + + + + + + + + &reftitle.returnvalues; + + This function returns a copy of str, + translating all occurrences of each character in + from to the corresponding character in + to. + + + + + &reftitle.changelog; + + + + + + &Version; + &Description; + + + + + 4.0.0 + + The optional to and from + parameters were added. + + + + + + + + + + &reftitle.examples; + + + <function>strtr</function> example + ]]> - - - - - strtr may be called with only two - arguments. If called with two arguments it behaves in a new way: - from then has to be an array that contains - string -> string pairs that will be replaced in the source - string. strtr will always look for the - longest possible match first and will *NOT* try to replace stuff - that it has already worked on. - - - <function>strtr</function> example with two arguments - + + + + + strtr may be called with only two + arguments. If called with two arguments it behaves in a new way: + from then has to be an array that contains + string -> string pairs that will be replaced in the source + string. strtr will always look for the + longest possible match first and will *NOT* try to replace stuff + that it has already worked on. + + + <function>strtr</function> example with two arguments + "hi", "hi" => "hello"); echo strtr("hi all, I said hello", $trans); ?> ]]> - - - This will show: - - + + &example.outputs; + - - - - - This optional to and - from parameters were added in PHP 4.0.0 - - - - See also ereg_replace. - - - + + + + + + &reftitle.seealso; + + + ereg_replace + + + +