bug38287.phpt 958 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. Bug #38287 (static variables mess up global vars)
  3. --FILE--
  4. <?php
  5. error_reporting(0);
  6. something::do_something();
  7. // $not_there is really NULL
  8. var_dump($not_there);
  9. // error occurs here: execution should never get inside the if condition because $not_there is NULL
  10. if ($not_there["invalid_var"]) {
  11. // will print NULL (which is ok, but execution should never get here if the value is NULL)
  12. var_dump($not_there["use_authmodule"]);
  13. // will print "PATH:Array"
  14. print "PATH:".$not_there["use_authmodule"]."\n";
  15. }
  16. class something {
  17. public static function get_object() {
  18. static $object=NULL;
  19. if ($object===NULL)
  20. $object=new something;
  21. return $object;
  22. }
  23. public static function do_something() {
  24. self::get_object()->vars[]=1;
  25. self::get_object()->vars[]=2;
  26. self::get_object()->vars[]=3;
  27. var_dump(self::get_object()->vars);
  28. }
  29. }
  30. ?>
  31. --EXPECT--
  32. array(3) {
  33. [0]=>
  34. int(1)
  35. [1]=>
  36. int(2)
  37. [2]=>
  38. int(3)
  39. }
  40. NULL