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