2007-10-08 15:21:13 +00:00
|
|
|
--TEST--
|
|
|
|
Test get_html_translation_table() function : basic functionality - table as HTML_SPECIALCHARS
|
|
|
|
--FILE--
|
|
|
|
<?php
|
2010-10-12 02:51:11 +00:00
|
|
|
/* Prototype : array get_html_translation_table ( [int $table [, int $quote_style [, string charset_hint]]] )
|
2007-10-08 15:21:13 +00:00
|
|
|
* Description: Returns the internal translation table used by htmlspecialchars and htmlentities
|
|
|
|
* Source code: ext/standard/html.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* test get_html_translation_table() when $table argument is specified as HTML_SPECIALCHARS */
|
|
|
|
|
|
|
|
echo "*** Testing get_html_translation_table() : basic functionality ***\n";
|
|
|
|
|
|
|
|
// $table as HTML_SEPCIALCHARS and different quote style
|
|
|
|
echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_COMPAT --\n";
|
|
|
|
$table = HTML_SPECIALCHARS;
|
|
|
|
$quote_style = ENT_COMPAT;
|
2010-10-12 02:51:11 +00:00
|
|
|
var_dump( get_html_translation_table($table, $quote_style, "UTF-8") );
|
2007-10-08 15:21:13 +00:00
|
|
|
|
2010-10-12 02:51:11 +00:00
|
|
|
echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_QUOTES --\n";
|
2007-10-08 15:21:13 +00:00
|
|
|
$quote_style = ENT_QUOTES;
|
2010-10-12 02:51:11 +00:00
|
|
|
var_dump( get_html_translation_table($table, $quote_style, "UTF-8") );
|
2007-10-08 15:21:13 +00:00
|
|
|
|
2010-10-12 02:51:11 +00:00
|
|
|
echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_NOQUOTES --\n";
|
2007-10-08 15:21:13 +00:00
|
|
|
$quote_style = ENT_NOQUOTES;
|
2010-10-12 02:51:11 +00:00
|
|
|
var_dump( get_html_translation_table($table, $quote_style, "UTF-8") );
|
2007-10-08 15:21:13 +00:00
|
|
|
|
|
|
|
echo "Done\n";
|
|
|
|
?>
|
|
|
|
--EXPECTF--
|
|
|
|
*** Testing get_html_translation_table() : basic functionality ***
|
|
|
|
-- with table = HTML_SPECIALCHARS & quote_style = ENT_COMPAT --
|
|
|
|
array(4) {
|
2010-10-12 02:51:11 +00:00
|
|
|
["&"]=>
|
|
|
|
string(5) "&"
|
2007-10-08 15:21:13 +00:00
|
|
|
["""]=>
|
|
|
|
string(6) """
|
|
|
|
["<"]=>
|
|
|
|
string(4) "<"
|
|
|
|
[">"]=>
|
|
|
|
string(4) ">"
|
|
|
|
}
|
2010-10-12 02:51:11 +00:00
|
|
|
-- with table = HTML_SPECIALCHARS & quote_style = ENT_QUOTES --
|
2007-10-08 15:21:13 +00:00
|
|
|
array(5) {
|
2010-10-12 02:51:11 +00:00
|
|
|
["&"]=>
|
|
|
|
string(5) "&"
|
2007-10-08 15:21:13 +00:00
|
|
|
["""]=>
|
|
|
|
string(6) """
|
|
|
|
["'"]=>
|
2010-10-12 02:51:11 +00:00
|
|
|
string(6) "'"
|
2007-10-08 15:21:13 +00:00
|
|
|
["<"]=>
|
|
|
|
string(4) "<"
|
|
|
|
[">"]=>
|
|
|
|
string(4) ">"
|
|
|
|
}
|
2010-10-12 02:51:11 +00:00
|
|
|
-- with table = HTML_SPECIALCHARS & quote_style = ENT_NOQUOTES --
|
2007-10-08 15:21:13 +00:00
|
|
|
array(3) {
|
2010-10-12 02:51:11 +00:00
|
|
|
["&"]=>
|
|
|
|
string(5) "&"
|
2007-10-08 15:21:13 +00:00
|
|
|
["<"]=>
|
|
|
|
string(4) "<"
|
|
|
|
[">"]=>
|
|
|
|
string(4) ">"
|
|
|
|
}
|
|
|
|
Done
|