1--TEST-- 2Test with compact literals 3--INI-- 4opcache.enable=1 5opcache.enable_cli=1 6opcache.optimization_level=-1 7--SKIPIF-- 8<?php require_once('skipif.inc'); ?> 9--FILE-- 10<?php 11 12echo "array key hash" . ":" . PHP_EOL; 13$array = array( 14 "1" => "one", 15 "2" => "two", 16 "one" => 1, 17 "two" => 2, 18); 19 20unset($array["one"]); 21unset($array["2"]); 22 23print_r($array); 24 25echo "function define" . ":" . PHP_EOL; 26if (!function_exists("dummy")) { 27 function dummy() { 28 var_dump(__FUNCTION__); 29 } 30} 31 32dummy(); 33 34$dummy = function () { var_dump("lambda" . "dummy"); }; 35$dummy(); 36 37if (!class_exists("A")) { 38 class A { 39 public static $name = "A"; 40 public static function say($n = "name") { 41 var_dump(static::$name); 42 } 43 } 44} 45 46class B extends A { 47 public static $name = "B"; 48} 49 50if (!class_exists("C")) { 51 class C extends B { 52 public static $name = "C"; 53 } 54} 55 56A::say(); 57B::Say(); 58A::say(); 59B::say(); 60C::say(); 61 62function get_eol_define() { 63 define("MY_EOL", PHP_EOL); 64} 65get_eol_define(); 66define("EOL", MY_EOL); 67 68echo "constants define" . ":" . EOL; 69 70echo "define " . "TEST" . EOL; 71define("TEST", "TEST"); 72 73class E { 74 public static $E="EP"; 75 const E="E"; 76 const TEST="NULL"; 77} 78 79class F { 80 const F="F"; 81 public static $E="FEP"; 82 const E="FE"; 83 const TEST="FALSE"; 84 public static $F = "FP"; 85} 86 87var_dump(TEST); //"TEST" 88var_dump(E::E); //"E" 89var_dump(F::E); //"FE" 90var_dump(F::F); //"F" 91var_dump(E::TEST); //"NULL" 92var_dump(F::TEST); //"FALSE" 93var_dump(E::$E); //"EP" 94var_dumP(F::$F); //"FP" 95var_dumP(F::$E); //"FEP" 96 97echo "propertes and methods" . EOL; 98 99class CH { 100 const H = "H"; 101 public function h() { 102 var_dump(self::H); 103 } 104} 105 106class CI { 107 const H = "I"; 108 public function h() { 109 var_dump(self::H); 110 } 111} 112 113function change(&$obj) { 114 $obj = new CH; 115} 116 117function geti() { 118 return new CI; 119} 120 121$h = new CH; 122 123echo "-->H" . PHP_EOL; 124$h->H(); 125var_dump($h::H); 126var_dump(CH::H); 127 128$h->H(); 129var_dump($h::H); 130var_dump(CH::H); 131 132echo "-->I" . PHP_EOL; 133$h = new CI; 134$h->H(); 135var_dump($h::H); 136var_dump(CI::H); 137$h->H(); 138var_dump($h::H); 139var_dump(CI::H); 140 141echo "-->H" . PHP_EOL; 142change($h); 143 144$h->H(); 145var_dump($h::H); 146var_dump(CH::H); 147 148$h->H(); 149var_dump($h::H); 150var_dump(CH::H); 151 152echo "-->I" . PHP_EOL; 153$h = geti(); 154$h->H(); 155var_dump($h::H); 156var_dump(CI::H); 157$h->H(); 158var_dump($h::H); 159var_dump(CI::H); 160?> 161--EXPECT-- 162array key hash: 163Array 164( 165 [1] => one 166 [two] => 2 167) 168function define: 169string(5) "dummy" 170string(11) "lambdadummy" 171string(1) "A" 172string(1) "B" 173string(1) "A" 174string(1) "B" 175string(1) "C" 176constants define: 177define TEST 178string(4) "TEST" 179string(1) "E" 180string(2) "FE" 181string(1) "F" 182string(4) "NULL" 183string(5) "FALSE" 184string(2) "EP" 185string(2) "FP" 186string(3) "FEP" 187propertes and methods 188-->H 189string(1) "H" 190string(1) "H" 191string(1) "H" 192string(1) "H" 193string(1) "H" 194string(1) "H" 195-->I 196string(1) "I" 197string(1) "I" 198string(1) "I" 199string(1) "I" 200string(1) "I" 201string(1) "I" 202-->H 203string(1) "H" 204string(1) "H" 205string(1) "H" 206string(1) "H" 207string(1) "H" 208string(1) "H" 209-->I 210string(1) "I" 211string(1) "I" 212string(1) "I" 213string(1) "I" 214string(1) "I" 215string(1) "I" 216