File indexing completed on 2024-04-28 15:52:52

0001 <?
0002 //various tests for lexer and parser
0003 class foo {
0004     const bar = 'bar';
0005 }
0006 $asdf = new foo;
0007 $asdf->somethingNew = true;
0008 
0009 function test($a=foo::bar) { echo $bar; }
0010 function test(array &$a=array()) {}
0011 function test2(foo $x, $y='blub') {}
0012 function test2($a=array("foo",1=>array(1,array()))) {}
0013 final class foo extends bar implements asdf, xxx {
0014     const asdf = 'asdf', xxx='foo';
0015     const asde = foo::blah;
0016     public static $x = array('asdf',);
0017     public abstract function asdf();
0018     public static function asdf($a, $foo=array(1, 2)) {}
0019 }
0020 interface asdf extends asf, xxx {
0021 }
0022 echo array();
0023 echo "$a\"\n";
0024 "$f\"bar";
0025 echo $i;
0026 echo $i[1];
0027 echo $i{1};
0028 echo $i['asdf'];
0029 echo $$i;
0030 echo $$i[1];
0031 echo $i[$j];
0032 print "foo";
0033 echo array(1,1,$i,'foo'=>$bar, 3=>&$x,);
0034 exit;
0035 exit();
0036 exit(1);
0037 die;
0038 die();
0039 echo (int)$i;
0040 echo (string)$i;
0041 echo (array)$i;
0042 echo (object)$i;
0043 echo (bool)$i;
0044 echo (unset)$i;
0045 echo isset($i);
0046 echo isset($i, $j);
0047 empty($i);
0048 include 'asdf';
0049 include_once 'asdf';
0050 require 'asdf';
0051 require_once 'asdf';
0052 eval('foo');
0053 echo @$j && @@$i;
0054 echo print print @@$foo;
0055 new a(1, 2==1, 1&&2);
0056 $i++;
0057 ++$i;
0058 $i+1;
0059 $i-1;
0060 2+3;
0061 $i++;
0062 1+1;
0063 ++$i;
0064 $i << 2;
0065 $i >> 3;
0066 (int)$i;
0067 (bool)$i + 1 / 3;
0068 new a(&$a);
0069 if ($i): echo $j; else: echo $i; endif;
0070 if (1) {} elseif (2) {} else if (2) {} else {}
0071 foo::bar;
0072 foo::$bar[1];
0073 bar(1);
0074 $$bar(1);
0075 $foo();
0076 $foo[1]();
0077 $foo[1]{1}();
0078 switch(1) {
0079     case 1:
0080         break;
0081 }
0082 switch(1) {
0083 }
0084 foo() or bar();
0085 ($a - 1);
0086 $foo->bar();
0087 $foo->bar->bar()->foo()->asdf[1];
0088 $i = !$i;
0089 $i == $i;
0090 $i != $i;
0091 $i === $i;
0092 $i !== $i;
0093 $i < $i;
0094 $i > $i;
0095 $i <= $i;
0096 $i >= $i;
0097 $i || $i;
0098 $i && $i;
0099 $i += $i;
0100 $i -= $i;
0101 $i *= $i;
0102 $i /= $i;
0103 $i .= $i;
0104 $i %= $i;
0105 $i &= $i;
0106 $i |= $i;
0107 $i ^= $i;
0108 $i <<= $i;
0109 $i >>= $i;
0110 $i->$i;
0111 for (;;) { }
0112 for (1;1;1,1) { }
0113 "\\";
0114 "\\\\";
0115 "\\\"";
0116 115.3e+1;
0117 115.3e-1;
0118 115.3e1;
0119 115.3e1165165;
0120 #comment
0121 //foo
0122 /** bar **/
0123 /*** bar **/
0124 @!$foo;
0125 @list($a) = @foo($b);
0126 self::${$bar};
0127 ${$bar};
0128 $$bar;
0129 $bar;
0130 $${$bar};
0131 $foo[1];
0132 ?>
0133 some html
0134 <?=$foo?>
0135 <?=$i; echo $b; ?>
0136 <?php if ( true ) : ?>
0137 foo
0138 <?php endif ?>
0139 <?php
0140 echo <<<EOD1
0141 barx$i
0142 asdf
0143 EOD1 xx
0144 EOD1;
0145 ?>
0146 <?php echo "foo"; //bar ?>
0147 <?php
0148 $foo = ($bar);
0149 $foo = (!$bar);
0150 ?>
0151 <?Php echo "a"; ?>
0152 <?php
0153 $i = '-V';
0154 echo `uptime $i`;
0155 "{$foo[bar]}";
0156 "\${$foo}";
0157 
0158 //from php manual
0159 echo "$beer's taste is great";
0160 echo "He drank some $beers";
0161 echo "He drank some ${beer}s";
0162 echo "He drank some {$beer}s";
0163 echo "A banana is $fruits[banana].";
0164 echo "A banana is {$fruits['banana']}.";
0165 echo "A banana is {$fruits[banana]}.";
0166 echo "A banana is " . $fruits['banana'] . ".";
0167 echo "This square is $square->width meters broad.";
0168 echo "This is { $great}";
0169 echo "This is {$great}";
0170 echo "This is ${great}";
0171 echo "This square is {$square->width}00 centimeters broad.";
0172 echo "This works: {$arr[4][3]}";
0173 echo "This is wrong: {$arr[foo][3]}";
0174 echo "This works: {$arr['foo'][3]}";
0175 echo "This works: " . $arr['foo'][3];
0176 echo "This works too: {$obj->values[3]->name}";
0177 echo "This is the value of the var named $name: {${$name}}";
0178 echo "This is the value of the var named by the return value of getName(): {${getName()}}";
0179 echo "This is the value of the var named by the return value of \$object->getName(): {${$object->getName()}}";
0180 
0181 $foo =& new bar() || exit;
0182 $foo =& bar() || bar();
0183 "{$foo["bar"]}";
0184 /*/*/
0185 
0186 while (1) {
0187 echo 'a' ?>jghjhfg
0188 <?php }
0189 class foo {
0190     var $settings = "foo \$bar";
0191 }
0192 ?>
0193 <? if (1) : ?><?=$foo?><? endif; ?>
0194 <? if (1) { ?><?=$foo?><? } ?>
0195 <?
0196 "{$foo[$i.'bar']}";
0197 "{$foo['bar'.$i]}";
0198 $i =& $a();
0199 $i =& new $a;
0200 $i =& $a;
0201 $i =& new $a(1,2,3);
0202 "${foo[a]}";
0203 "${foo}";
0204 $blah = 'blah';
0205 $foo =& $blah || die($i);
0206 $foo =& $blah() || die($i);
0207 if (true) { ?>
0208 <? echo "foo"; ?>
0209 <?="bar";?>
0210 <? }
0211