1--TEST-- 2Test htmlspecialchars() function : basic functionality 3--FILE-- 4<?php 5echo "*** Testing htmlspecialchars() : basic functionality ***\n"; 6 7$s1 = "abc<>\"&\n"; 8$s2 = "&&abc<>\"&\n"; 9$s3 = "a>,\<bc<>\"&\n"; 10$s4 = "a\'\'&bc<>\"&\n"; 11$s5 = "&<\n"; 12echo "Basic tests\n"; 13echo "Test 1: " . htmlspecialchars ($s1); 14echo "Test 2: " . htmlspecialchars ($s2); 15echo "Test 3: " . htmlspecialchars ($s3); 16echo "Test 4: " . htmlspecialchars ($s4); 17echo "Test 5: " . htmlspecialchars ($s5); 18echo "Test 6: " . htmlspecialchars ($s1,ENT_NOQUOTES); 19echo "Test 7: " . htmlspecialchars ($s2,ENT_NOQUOTES); 20echo "Test 8: " . htmlspecialchars ($s3,ENT_NOQUOTES); 21echo "Test 9: " . htmlspecialchars ($s4,ENT_NOQUOTES); 22echo "Test 10: " . htmlspecialchars ($s5,ENT_NOQUOTES); 23echo "Test 11: " . htmlspecialchars ($s1,ENT_COMPAT); 24echo "Test 12: " . htmlspecialchars ($s2,ENT_COMPAT); 25echo "Test 13: " . htmlspecialchars ($s3,ENT_COMPAT); 26echo "Test 14: " . htmlspecialchars ($s4,ENT_COMPAT); 27echo "Test 15: " . htmlspecialchars ($s5,ENT_COMPAT); 28echo "Test 16: " . htmlspecialchars ($s1,ENT_QUOTES); 29echo "Test 17: " . htmlspecialchars ($s2,ENT_QUOTES); 30echo "Test 18: " . htmlspecialchars ($s3,ENT_QUOTES); 31echo "Test 19: " . htmlspecialchars ($s4,ENT_QUOTES); 32echo "Test 20: " . htmlspecialchars ($s5,ENT_QUOTES); 33 34echo "\nTry with char set option - specify default ISO-8859-1\n"; 35echo "Test 21: " . htmlspecialchars ($s1,ENT_NOQUOTES, "ISO-8859-1"); 36echo "Test 22: " . htmlspecialchars ($s2,ENT_COMPAT, "ISO-8859-1"); 37echo "Test 23: " . htmlspecialchars ($s3,ENT_QUOTES, "ISO-8859-1"); 38echo "Test 24: " . htmlspecialchars ($s5,ENT_QUOTES, "ISO-8859-1"); 39 40echo "\nTry with double decode FALSE\n"; 41$s1 = ""&xyz>abc"\n"; 42$s2 = ""&123<456"\n"; 43$s3 = "\"300 < 400\"\n"; 44echo "Test 25: " . htmlspecialchars ($s1,ENT_NOQUOTES, "ISO-8859-1", false); 45echo "Test 26: " . htmlspecialchars ($s2,ENT_NOQUOTES, "ISO-8859-1", false); 46echo "Test 27: " . htmlspecialchars ($s3,ENT_NOQUOTES, "ISO-8859-1", false); 47 48echo "\nTry with double decode TRUE\n"; 49echo "Test 28: " . htmlspecialchars ($s1, ENT_NOQUOTES, "ISO-8859-1", true); 50echo "Test 29: " . htmlspecialchars ($s2, ENT_NOQUOTES, "ISO-8859-1", true); 51 52?> 53--EXPECT-- 54*** Testing htmlspecialchars() : basic functionality *** 55Basic tests 56Test 1: abc<>"& 57Test 2: &&abc<>"& 58Test 3: a>,\<bc<>"& 59Test 4: a\'\'&bc<>"& 60Test 5: &amp;&lt; 61Test 6: abc<>"& 62Test 7: &&abc<>"& 63Test 8: a>,\<bc<>"& 64Test 9: a\'\'&bc<>"& 65Test 10: &amp;&lt; 66Test 11: abc<>"& 67Test 12: &&abc<>"& 68Test 13: a>,\<bc<>"& 69Test 14: a\'\'&bc<>"& 70Test 15: &amp;&lt; 71Test 16: abc<>"& 72Test 17: &&abc<>"& 73Test 18: a>,\<bc<>"& 74Test 19: a\'\'&bc<>"& 75Test 20: &amp;&lt; 76 77Try with char set option - specify default ISO-8859-1 78Test 21: abc<>"& 79Test 22: &&abc<>"& 80Test 23: a>,\<bc<>"& 81Test 24: &amp;&lt; 82 83Try with double decode FALSE 84Test 25: "&xyz>abc" 85Test 26: "&123<456" 86Test 27: "300 < 400" 87 88Try with double decode TRUE 89Test 28: &quot;&amp;xyz&gt;abc&quot; 90Test 29: &quot;&amp;123&lt;456&quot; 91