1Literals 2----- 3<?php 4 5// magic constants 6__LINE__; 7__FILE__; 8__DIR__; 9__FUNCTION__; 10__CLASS__; 11__TRAIT__; 12__METHOD__; 13__NAMESPACE__; 14__PROPERTY__; 15 16// not actually literals, but close 17null; 18true; 19false; 20NULL; 21TRUE; 22FALSE; 23 24// integers (normalized to decimal) 250; 2611; 27011; 280x11; 290b11; 30 31// floats (normalized to ... something) 320.; 33.0; 340.0; 350e1000; 361.0; 371e100; 381e1000; 391E-100; 401000000000000000000000000000000000000000000000000000000000000000000000000000000000000; 41378282246310005.0; 4210000000000000002.0; 43 44// strings (single quoted) 45'a'; 46'a 47b'; 48'a\'b'; 49'a\b'; 50'a\\'; 51'a\\\\b'; 52'a\\\'b'; 53 54// strings (double quoted) 55"a"; 56"a\nb"; 57"a'b"; 58"a\b"; 59"$a"; 60"a$b"; 61"$a$b"; 62"$a $b"; 63"a${b}c"; 64"a{$b}c"; 65"a$a[b]c"; 66"\{$A}"; 67"\{ $A }"; 68"\\{$A}"; 69"\\{ $A }"; 70"{$$A}[B]"; 71"$$A[B]"; 72 73// make sure indentation doesn't mess anything up 74function foo() 75{ 76 "a\nb"; 77 'a 78b'; 79 'a 80 b'; 81} 82 83// shell exec (similar to double quoted string) 84`foo`; 85`foo$a`; 86`foo{$a}bar`; 87`\`\'\"`; 88----- 89// magic constants 90__LINE__; 91__FILE__; 92__DIR__; 93__FUNCTION__; 94__CLASS__; 95__TRAIT__; 96__METHOD__; 97__NAMESPACE__; 98__PROPERTY__; 99// not actually literals, but close 100null; 101true; 102false; 103NULL; 104TRUE; 105FALSE; 106// integers (normalized to decimal) 1070; 10811; 109011; 1100x11; 1110b11; 112// floats (normalized to ... something) 1130.0; 1140.0; 1150.0; 1160.0; 1171.0; 1181.0E+100; 1191.0E+1000; 1201.0E-100; 1211.0E+84; 122378282246310005.0; 12310000000000000002.0; 124// strings (single quoted) 125'a'; 126'a 127b'; 128'a\'b'; 129'a\b'; 130'a\\'; 131'a\\\\b'; 132'a\\\'b'; 133// strings (double quoted) 134"a"; 135"a\nb"; 136"a'b"; 137"a\\b"; 138"{$a}"; 139"a{$b}"; 140"{$a}{$b}"; 141"{$a} {$b}"; 142"a{$b}c"; 143"a{$b}c"; 144"a{$a['b']}c"; 145"\\{{$A}}"; 146"\\{ {$A} }"; 147"\\{$A}"; 148"\\{ {$A} }"; 149"{${$A}}[B]"; 150"\${$A['B']}"; 151// make sure indentation doesn't mess anything up 152function foo() 153{ 154 "a\nb"; 155 'a 156b'; 157 'a 158 b'; 159} 160// shell exec (similar to double quoted string) 161`foo`; 162`foo{$a}`; 163`foo{$a}bar`; 164`\`\\'\\"`; 165