1--TEST-- 2Test htmlspecialchars_decode() function : usage variations - double quoted strings for 'string' argument 3--FILE-- 4<?php 5/* Prototype : string htmlspecialchars_decode(string $string [, int $quote_style]) 6 * Description: Convert special HTML entities back to characters 7 * Source code: ext/standard/html.c 8*/ 9 10/* 11 * testing htmlspecialchars_decode() for various double quoted strings as argument for $string 12*/ 13echo "*** Testing htmlspecialchars_decode() : usage variations ***\n"; 14 15//double quoted strings 16$strings = array ( 17 "Roy's height > Sam's \$height... 1111 ≈ 0000 = 0000... " double quote string "", 18 "Roy's height > Sam's height... \t\t 13 < 15...\n\r " double quote\f\v string "", 19 "\nRoy's height >\t; Sam's\v height\f", 20 "\r\tRoy's height >\r; Sam\t's height", 21 "\n 1\t3 &\tgt; 11 but 11 &\tlt; 12", 22); 23 24// loop through each element of the array to check htmlspecialchars_decode() function with all possible arguments 25$iterator = 1; 26foreach($strings as $value) { 27 echo "-- Iteration $iterator --\n"; 28 var_dump( htmlspecialchars_decode($value) ); 29 var_dump( htmlspecialchars_decode($value, ENT_COMPAT) ); 30 var_dump( htmlspecialchars_decode($value, ENT_NOQUOTES) ); 31 var_dump( htmlspecialchars_decode($value, ENT_QUOTES) ); 32 $iterator++; 33} 34 35echo "Done"; 36?> 37--EXPECTF-- 38*** Testing htmlspecialchars_decode() : usage variations *** 39-- Iteration 1 -- 40string(89) "Roy's height > Sam's $height... 1111 ≈ 0000 = 0000... " double quote string "" 41string(89) "Roy's height > Sam's $height... 1111 ≈ 0000 = 0000... " double quote string "" 42string(99) "Roy's height > Sam's $height... 1111 ≈ 0000 = 0000... " double quote string "" 43string(84) "Roy's height > Sam's $height... 1111 ≈ 0000 = 0000... " double quote string "" 44-- Iteration 2 -- 45string(82) "Roy's height > Sam's height... 13 < 15... 46 46 " double quote string "" 47string(82) "Roy's height > Sam's height... 13 < 15... 48 48 " double quote string "" 49string(92) "Roy's height > Sam's height... 13 < 15... 50 50 " double quote string "" 51string(72) "Roy's height > Sam's height... 13 < 15... 52 52 " double quote string "" 53-- Iteration 3 -- 54string(44) " 55Roy's height > ; Sam's height" 56string(44) " 57Roy's height > ; Sam's height" 58string(44) " 59Roy's height > ; Sam's height" 60string(34) " 61Roy's height > ; Sam's height" 62-- Iteration 4 -- 63string(44) " 63 Roy's height > 63; Sam 's height" 64string(44) " 64 Roy's height > 64; Sam 's height" 65string(44) " 65 Roy's height > 65; Sam 's height" 66string(34) " 66 Roy's height > 66; Sam 's height" 67-- Iteration 5 -- 68string(30) " 69 1 3 & gt; 11 but 11 & lt; 12" 70string(30) " 71 1 3 & gt; 11 but 11 & lt; 12" 72string(30) " 73 1 3 & gt; 11 but 11 & lt; 12" 74string(30) " 75 1 3 & gt; 11 but 11 & lt; 12" 76Done