test.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. if (isset($include)) {
  3. include (sprintf("%s/web-bootstrap.php", dirname(__FILE__)));
  4. }
  5. $stdout = fopen("php://stdout", "w+");
  6. class phpdbg {
  7. private $sprintf = "%s: %s\n";
  8. public function isGreat($greeting = null) {
  9. printf($this->sprintf, __METHOD__, $greeting);
  10. return $this;
  11. }
  12. }
  13. function mine() {
  14. var_dump(func_get_args());
  15. }
  16. function test($x, $y = 0) {
  17. $var = $x + 1;
  18. $var += 2;
  19. $var <<= 3;
  20. $foo = function () {
  21. echo "bar!\n";
  22. };
  23. $foo();
  24. yield $var;
  25. }
  26. $dbg = new phpdbg();
  27. var_dump(
  28. $dbg->isGreat("PHP Rocks!!"));
  29. foreach (test(1,2) as $gen)
  30. continue;
  31. echo "it works!\n";
  32. if (isset($dump))
  33. var_dump($_SERVER);
  34. function phpdbg_test_ob()
  35. {
  36. echo 'Start';
  37. ob_start();
  38. echo 'Hello';
  39. $b = ob_get_clean();
  40. echo 'End';
  41. echo $b;
  42. }
  43. $array = [
  44. 1,
  45. 2,
  46. [3, 4],
  47. [5, 6],
  48. ];
  49. $array[] = 7;
  50. array_walk($array, function (&$item) {
  51. if (is_array($item))
  52. $item[0] += 2;
  53. else
  54. $item -= 1;
  55. });
  56. class testClass {
  57. public $a = 2;
  58. protected $b = [1, 3];
  59. private $c = 7;
  60. }
  61. $obj = new testClass;
  62. $test = $obj->a;
  63. $obj->a += 2;
  64. $test -= 2;
  65. unset($obj);