1--TEST-- 2Test htmlspecialchars_decode() function : usage variations - heredoc strings for 'string' argument 3--FILE-- 4<?php 5/* 6 * testing htmlspecialchars_decode() with various heredoc strings as argument for $string 7*/ 8 9echo "*** Testing htmlspecialchars_decode() : usage variations ***\n"; 10 11// empty heredoc string 12$empty_string = <<<EOT 13EOT; 14 15// Heredoc string with blank line 16$blank_line = <<<EOT 17 18EOT; 19 20// heredoc with multiline string 21$multiline_string = <<<EOT 22<html>Roy's height > Sam's height 2313 < 25 241111 & 0000 = 0000 25"This is a double quoted string" 26EOT; 27 28// heredoc with different whitespaces 29$diff_whitespaces = <<<EOT 30<html>Roy's height\r > Sam\t's height 311111\t\t & 0000\v\v = \f0000 32" heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces" 33EOT; 34 35// heredoc with numeric values 36$numeric_string = <<<EOT 37<html>11 < 12. 123 string 4567 38"string" 1111\t & 0000\t = 0000\n; 39EOT; 40 41// heredoc with quote chars & slash 42$quote_char_string = <<<EOT 43<html>< This's a string with quotes: 44"strings in double quote" & 45'strings in single quote' " 46this\line is 'single quoted' /with\slashes </html> 47EOT; 48 49$res_heredoc_strings = array( 50 //heredoc strings 51 $empty_string, 52 $blank_line, 53 $multiline_string, 54 $diff_whitespaces, 55 $numeric_string, 56 $quote_char_string 57); 58 59// loop through $res_heredoc_strings array and check the working on htmlspecialchars_decode() 60$count = 1; 61for($index =0; $index < count($res_heredoc_strings); $index ++) { 62 echo "-- Iteration $count --\n"; 63 var_dump( htmlspecialchars_decode($res_heredoc_strings[$index]) ); 64 $count++; 65} 66 67echo "Done\n"; 68?> 69--EXPECT-- 70*** Testing htmlspecialchars_decode() : usage variations *** 71-- Iteration 1 -- 72string(0) "" 73-- Iteration 2 -- 74string(0) "" 75-- Iteration 3 -- 76string(93) "<html>Roy's height > Sam's height 7713 < 25 781111 & 0000 = 0000 79"This is a double quoted string"" 80-- Iteration 4 -- 81string(120) "<html>Roy's height 82 > Sam 's height 831111 & 0000 = 0000 84" heredoc 85double quoted string. withdifferentwhitespaces"" 86-- Iteration 5 -- 87string(62) "<html>11 < 12. 123 string 4567 88"string" 1111 & 0000 = 0000 89;" 90-- Iteration 6 -- 91string(143) "<html>< This's a string with quotes: 92"strings in double quote" & 93'strings in single quote' " 94this\line is 'single quoted' /with\slashes </html>" 95Done 96