1Tests for entering and leaving PHP mode 2 3Expected output is 4 5functions: 6 a 7 b 8 c 9 d 10 e 11 f 12 g 13 h 14 i 15 j 16 17 18function bug0() { 19 // this should not appear 20} 21 22<?php // entering PHP mode, classic method 23 24function a() {} 25 26?> // PHP mode left 27 28function bug1() {} 29 30<? // entering PHP mode, short open tag 31 32function b() {} 33 34?> // PHP mode left 35 36function bug2() {} 37 38<?php // entering PHP mode 39 40// this WILL leave PHP mode: ?> 41 42function bug3() {} 43 44<? // entering PHP mode 45 46function c() { 47 ?> // PHP mode left 48 function bug4() { 49 } 50 <? // back to PHP mode, still inside function c() 51} 52 53function d() { 54 ?> // same here 55 function bug5() { 56 } 57 <?php // back to PHP mode, still inside function d() 58} 59 60// any open tag matches any close tag, so this is valid 61</script> // leaves PHP mode 62 63function bug4() {} 64 65?> <!-- just in case --> 66 67<script language="php"> // enetered PHP mode 68 69function e() { 70 return 42; 71} 72 73?> // left PHP mode 74 75function bug5() {} 76 77// some valid long tag opening with inner whitespaces 78 79<script 80 language 81 = 82 php 83> // entered 84function f() {} 85</script 86 > // left 87 88function bug6() {} 89 90<script language= 'php' > // enter 91function g() {} 92</script > // leave 93 94function bug7() {} 95 96<?php 97// this WON'T leave PHP mode, it's in a comment </script> 98function h() {} 99?> 100 101function bug8() {} 102 103<?php 104 105function i() {} 106// any open tag matches any close tag, so this is valid 107</script 108 > 109 110function bug9() {} 111 112// this won't enter PHP, no spaces are allowed between the "<" and "script" 113< script language = php > 114 115function bug10() {} 116 117// does nothing, just resets mode for some tools not aware of the "script" thing 118?> 119 120<!-- <script> is OK anywhere, even in XML strings --> 121<p attr="<script language=php> 122function j() {} 123</script>"> 124 125</p> 126