2007-09-29 09:03:22 +00:00
|
|
|
|
--TEST--
|
|
|
|
|
Test htmlspecialchars_decode() function : usage variations - heredoc strings for 'string' argument
|
|
|
|
|
--FILE--
|
|
|
|
|
<?php
|
|
|
|
|
/* Prototype : string htmlspecialchars_decode(string $string [, int $quote_style])
|
|
|
|
|
* Description: Convert special HTML entities back to characters
|
|
|
|
|
* Source code: ext/standard/html.c
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* testing htmlspecialchars_decode() with various heredoc strings as argument for $string
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
echo "*** Testing htmlspecialchars_decode() : usage variations ***\n";
|
|
|
|
|
|
|
|
|
|
// empty heredoc string
|
|
|
|
|
$empty_string = <<<EOT
|
|
|
|
|
EOT;
|
|
|
|
|
|
|
|
|
|
// Heredoc string with blank line
|
|
|
|
|
$blank_line = <<<EOT
|
|
|
|
|
|
|
|
|
|
EOT;
|
|
|
|
|
|
|
|
|
|
// heredoc with multiline string
|
|
|
|
|
$multiline_string = <<<EOT
|
|
|
|
|
<html>Roy's height > Sam's height
|
|
|
|
|
13 < 25
|
|
|
|
|
1111 & 0000 = 0000
|
|
|
|
|
"This is a double quoted string"
|
|
|
|
|
EOT;
|
|
|
|
|
|
|
|
|
|
// heredoc with diferent whitespaces
|
|
|
|
|
$diff_whitespaces = <<<EOT
|
|
|
|
|
<html>Roy's height\r > Sam\t's height
|
|
|
|
|
1111\t\t & 0000\v\v = \f0000
|
|
|
|
|
" heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces"
|
|
|
|
|
EOT;
|
|
|
|
|
|
|
|
|
|
// heredoc with numeric values
|
|
|
|
|
$numeric_string = <<<EOT
|
|
|
|
|
<html>11 < 12. 123 string 4567
|
|
|
|
|
"string" 1111\t & 0000\t = 0000\n;
|
|
|
|
|
EOT;
|
|
|
|
|
|
|
|
|
|
// heredoc with quote chars & slash
|
|
|
|
|
$quote_char_string = <<<EOT
|
|
|
|
|
<html>< This's a string with quotes:
|
|
|
|
|
"strings in double quote" &
|
|
|
|
|
'strings in single quote' "
|
|
|
|
|
this\line is 'single quoted' /with\slashes </html>
|
|
|
|
|
EOT;
|
|
|
|
|
|
|
|
|
|
$res_heredoc_strings = array(
|
|
|
|
|
//heredoc strings
|
|
|
|
|
$empty_string,
|
|
|
|
|
$blank_line,
|
|
|
|
|
$multiline_string,
|
|
|
|
|
$diff_whitespaces,
|
|
|
|
|
$numeric_string,
|
|
|
|
|
$quote_char_string
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// loop through $res_heredoc_strings array and check the working on htmlspecialchars_decode()
|
|
|
|
|
$count = 1;
|
|
|
|
|
for($index =0; $index < count($res_heredoc_strings); $index ++) {
|
|
|
|
|
echo "-- Iteration $count --\n";
|
|
|
|
|
var_dump( htmlspecialchars_decode($res_heredoc_strings[$index]) );
|
|
|
|
|
$count++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo "Done\n";
|
|
|
|
|
?>
|
2008-05-27 10:50:48 +00:00
|
|
|
|
--EXPECT--
|
2007-09-29 09:03:22 +00:00
|
|
|
|
*** Testing htmlspecialchars_decode() : usage variations ***
|
|
|
|
|
-- Iteration 1 --
|
|
|
|
|
unicode(0) ""
|
|
|
|
|
-- Iteration 2 --
|
|
|
|
|
unicode(0) ""
|
|
|
|
|
-- Iteration 3 --
|
|
|
|
|
unicode(103) "<html>Roy's height > Sam's height
|
|
|
|
|
13 < 25
|
|
|
|
|
1111 & 0000 = 0000
|
|
|
|
|
"This is a double quoted string""
|
|
|
|
|
-- Iteration 4 --
|
2009-07-15 14:08:18 +00:00
|
|
|
|
unicode(130) "<html>Roy's height
> Sam 's height
|
2007-09-29 09:03:22 +00:00
|
|
|
|
1111 & 0000 = 0000
|
|
|
|
|
" heredoc
|
|
|
|
|
double quoted string. withdifferentwhitespaces""
|
|
|
|
|
-- Iteration 5 --
|
|
|
|
|
unicode(62) "<html>11 < 12. 123 string 4567
|
|
|
|
|
"string" 1111 & 0000 = 0000
|
|
|
|
|
;"
|
|
|
|
|
-- Iteration 6 --
|
|
|
|
|
unicode(153) "<html>< This's a string with quotes:
|
|
|
|
|
"strings in double quote" &
|
|
|
|
|
'strings in single quote' "
|
|
|
|
|
this\line is 'single quoted' /with\slashes </html>"
|
|
|
|
|
Done
|