1--TEST-- 2Test htmlspecialchars() function 3--FILE-- 4<?php 5/* retrieving htmlspecialchars from the ANSI character table */ 6echo "*** Retrieving htmlspecialchars for 256 characters ***\n"; 7for($i=0; $i<256; $i++) 8var_dump( bin2hex( htmlspecialchars("chr($i)") ) ); 9 10/* giving NULL as the argument */ 11echo "\n*** Testing htmlspecialchars() with NULL as first, second and third argument ***\n"; 12var_dump( htmlspecialchars("<br>", ENT_NOQUOTES, NULL) ); 13var_dump( htmlspecialchars("<br>", ENT_QUOTES, NULL) ); 14var_dump( htmlspecialchars("<br>", ENT_COMPAT, NULL) ); 15 16/* giving long string to check for proper memory re-allocation */ 17echo "\n*** Checking a long string for proper memory allocation ***\n"; 18var_dump( htmlspecialchars("<br>Testing<p>New file.</p><p><br>File <b><i><u>WORKS!!!</i></u></b></p><br><p>End of file!!!</p>", ENT_QUOTES, 'iso-8859-1' ) ); 19 20/* Giving a normal string */ 21echo "\n*** Testing a normal string with htmlspecialchars() ***\n"; 22var_dump( htmlspecialchars("<br>Testing<p>New file.</p> ", ENT_QUOTES, 'iso-8859-1' ) ); 23 24/* checking behavior of quote */ 25echo "\n*** Testing htmlspecialchars() on a quote...\n"; 26$str = "A 'quote' is <b>bold</b>"; 27var_dump( htmlspecialchars($str) ); 28var_dump( htmlspecialchars($str, ENT_QUOTES) ); 29var_dump( htmlspecialchars($str, ENT_NOQUOTES) ); 30var_dump( htmlspecialchars($str, ENT_COMPAT) ); 31 32echo "Done\n" 33?> 34--EXPECT-- 35*** Retrieving htmlspecialchars for 256 characters *** 36string(12) "636872283029" 37string(12) "636872283129" 38string(12) "636872283229" 39string(12) "636872283329" 40string(12) "636872283429" 41string(12) "636872283529" 42string(12) "636872283629" 43string(12) "636872283729" 44string(12) "636872283829" 45string(12) "636872283929" 46string(14) "63687228313029" 47string(14) "63687228313129" 48string(14) "63687228313229" 49string(14) "63687228313329" 50string(14) "63687228313429" 51string(14) "63687228313529" 52string(14) "63687228313629" 53string(14) "63687228313729" 54string(14) "63687228313829" 55string(14) "63687228313929" 56string(14) "63687228323029" 57string(14) "63687228323129" 58string(14) "63687228323229" 59string(14) "63687228323329" 60string(14) "63687228323429" 61string(14) "63687228323529" 62string(14) "63687228323629" 63string(14) "63687228323729" 64string(14) "63687228323829" 65string(14) "63687228323929" 66string(14) "63687228333029" 67string(14) "63687228333129" 68string(14) "63687228333229" 69string(14) "63687228333329" 70string(14) "63687228333429" 71string(14) "63687228333529" 72string(14) "63687228333629" 73string(14) "63687228333729" 74string(14) "63687228333829" 75string(14) "63687228333929" 76string(14) "63687228343029" 77string(14) "63687228343129" 78string(14) "63687228343229" 79string(14) "63687228343329" 80string(14) "63687228343429" 81string(14) "63687228343529" 82string(14) "63687228343629" 83string(14) "63687228343729" 84string(14) "63687228343829" 85string(14) "63687228343929" 86string(14) "63687228353029" 87string(14) "63687228353129" 88string(14) "63687228353229" 89string(14) "63687228353329" 90string(14) "63687228353429" 91string(14) "63687228353529" 92string(14) "63687228353629" 93string(14) "63687228353729" 94string(14) "63687228353829" 95string(14) "63687228353929" 96string(14) "63687228363029" 97string(14) "63687228363129" 98string(14) "63687228363229" 99string(14) "63687228363329" 100string(14) "63687228363429" 101string(14) "63687228363529" 102string(14) "63687228363629" 103string(14) "63687228363729" 104string(14) "63687228363829" 105string(14) "63687228363929" 106string(14) "63687228373029" 107string(14) "63687228373129" 108string(14) "63687228373229" 109string(14) "63687228373329" 110string(14) "63687228373429" 111string(14) "63687228373529" 112string(14) "63687228373629" 113string(14) "63687228373729" 114string(14) "63687228373829" 115string(14) "63687228373929" 116string(14) "63687228383029" 117string(14) "63687228383129" 118string(14) "63687228383229" 119string(14) "63687228383329" 120string(14) "63687228383429" 121string(14) "63687228383529" 122string(14) "63687228383629" 123string(14) "63687228383729" 124string(14) "63687228383829" 125string(14) "63687228383929" 126string(14) "63687228393029" 127string(14) "63687228393129" 128string(14) "63687228393229" 129string(14) "63687228393329" 130string(14) "63687228393429" 131string(14) "63687228393529" 132string(14) "63687228393629" 133string(14) "63687228393729" 134string(14) "63687228393829" 135string(14) "63687228393929" 136string(16) "6368722831303029" 137string(16) "6368722831303129" 138string(16) "6368722831303229" 139string(16) "6368722831303329" 140string(16) "6368722831303429" 141string(16) "6368722831303529" 142string(16) "6368722831303629" 143string(16) "6368722831303729" 144string(16) "6368722831303829" 145string(16) "6368722831303929" 146string(16) "6368722831313029" 147string(16) "6368722831313129" 148string(16) "6368722831313229" 149string(16) "6368722831313329" 150string(16) "6368722831313429" 151string(16) "6368722831313529" 152string(16) "6368722831313629" 153string(16) "6368722831313729" 154string(16) "6368722831313829" 155string(16) "6368722831313929" 156string(16) "6368722831323029" 157string(16) "6368722831323129" 158string(16) "6368722831323229" 159string(16) "6368722831323329" 160string(16) "6368722831323429" 161string(16) "6368722831323529" 162string(16) "6368722831323629" 163string(16) "6368722831323729" 164string(16) "6368722831323829" 165string(16) "6368722831323929" 166string(16) "6368722831333029" 167string(16) "6368722831333129" 168string(16) "6368722831333229" 169string(16) "6368722831333329" 170string(16) "6368722831333429" 171string(16) "6368722831333529" 172string(16) "6368722831333629" 173string(16) "6368722831333729" 174string(16) "6368722831333829" 175string(16) "6368722831333929" 176string(16) "6368722831343029" 177string(16) "6368722831343129" 178string(16) "6368722831343229" 179string(16) "6368722831343329" 180string(16) "6368722831343429" 181string(16) "6368722831343529" 182string(16) "6368722831343629" 183string(16) "6368722831343729" 184string(16) "6368722831343829" 185string(16) "6368722831343929" 186string(16) "6368722831353029" 187string(16) "6368722831353129" 188string(16) "6368722831353229" 189string(16) "6368722831353329" 190string(16) "6368722831353429" 191string(16) "6368722831353529" 192string(16) "6368722831353629" 193string(16) "6368722831353729" 194string(16) "6368722831353829" 195string(16) "6368722831353929" 196string(16) "6368722831363029" 197string(16) "6368722831363129" 198string(16) "6368722831363229" 199string(16) "6368722831363329" 200string(16) "6368722831363429" 201string(16) "6368722831363529" 202string(16) "6368722831363629" 203string(16) "6368722831363729" 204string(16) "6368722831363829" 205string(16) "6368722831363929" 206string(16) "6368722831373029" 207string(16) "6368722831373129" 208string(16) "6368722831373229" 209string(16) "6368722831373329" 210string(16) "6368722831373429" 211string(16) "6368722831373529" 212string(16) "6368722831373629" 213string(16) "6368722831373729" 214string(16) "6368722831373829" 215string(16) "6368722831373929" 216string(16) "6368722831383029" 217string(16) "6368722831383129" 218string(16) "6368722831383229" 219string(16) "6368722831383329" 220string(16) "6368722831383429" 221string(16) "6368722831383529" 222string(16) "6368722831383629" 223string(16) "6368722831383729" 224string(16) "6368722831383829" 225string(16) "6368722831383929" 226string(16) "6368722831393029" 227string(16) "6368722831393129" 228string(16) "6368722831393229" 229string(16) "6368722831393329" 230string(16) "6368722831393429" 231string(16) "6368722831393529" 232string(16) "6368722831393629" 233string(16) "6368722831393729" 234string(16) "6368722831393829" 235string(16) "6368722831393929" 236string(16) "6368722832303029" 237string(16) "6368722832303129" 238string(16) "6368722832303229" 239string(16) "6368722832303329" 240string(16) "6368722832303429" 241string(16) "6368722832303529" 242string(16) "6368722832303629" 243string(16) "6368722832303729" 244string(16) "6368722832303829" 245string(16) "6368722832303929" 246string(16) "6368722832313029" 247string(16) "6368722832313129" 248string(16) "6368722832313229" 249string(16) "6368722832313329" 250string(16) "6368722832313429" 251string(16) "6368722832313529" 252string(16) "6368722832313629" 253string(16) "6368722832313729" 254string(16) "6368722832313829" 255string(16) "6368722832313929" 256string(16) "6368722832323029" 257string(16) "6368722832323129" 258string(16) "6368722832323229" 259string(16) "6368722832323329" 260string(16) "6368722832323429" 261string(16) "6368722832323529" 262string(16) "6368722832323629" 263string(16) "6368722832323729" 264string(16) "6368722832323829" 265string(16) "6368722832323929" 266string(16) "6368722832333029" 267string(16) "6368722832333129" 268string(16) "6368722832333229" 269string(16) "6368722832333329" 270string(16) "6368722832333429" 271string(16) "6368722832333529" 272string(16) "6368722832333629" 273string(16) "6368722832333729" 274string(16) "6368722832333829" 275string(16) "6368722832333929" 276string(16) "6368722832343029" 277string(16) "6368722832343129" 278string(16) "6368722832343229" 279string(16) "6368722832343329" 280string(16) "6368722832343429" 281string(16) "6368722832343529" 282string(16) "6368722832343629" 283string(16) "6368722832343729" 284string(16) "6368722832343829" 285string(16) "6368722832343929" 286string(16) "6368722832353029" 287string(16) "6368722832353129" 288string(16) "6368722832353229" 289string(16) "6368722832353329" 290string(16) "6368722832353429" 291string(16) "6368722832353529" 292 293*** Testing htmlspecialchars() with NULL as first, second and third argument *** 294string(10) "<br>" 295string(10) "<br>" 296string(10) "<br>" 297 298*** Checking a long string for proper memory allocation *** 299string(187) "<br>Testing<p>New file.</p><p><br>File <b><i><u>WORKS!!!</i></u></b></p><br><p>End of file!!!</p>" 300 301*** Testing a normal string with htmlspecialchars() *** 302string(46) "<br>Testing<p>New file.</p> " 303 304*** Testing htmlspecialchars() on a quote... 305string(46) "A 'quote' is <b>bold</b>" 306string(46) "A 'quote' is <b>bold</b>" 307string(36) "A 'quote' is <b>bold</b>" 308string(36) "A 'quote' is <b>bold</b>" 309Done 310