php-src/sapi/phpdbg/test.php

88 lines
1.1 KiB
PHP
Raw Normal View History

2013-11-10 13:01:46 +00:00
<?php
2013-11-25 10:17:57 +00:00
if (isset($include)) {
2013-11-17 16:13:13 +00:00
include (sprintf("%s/web-bootstrap.php", dirname(__FILE__)));
2013-11-25 10:17:57 +00:00
}
2013-11-18 23:18:22 +00:00
$stdout = fopen("php://stdout", "w+");
2013-11-13 09:17:58 +00:00
class phpdbg {
private $sprintf = "%s: %s\n";
public function isGreat($greeting = null) {
printf($this->sprintf, __METHOD__, $greeting);
return $this;
}
}
2014-02-24 22:30:46 +00:00
function mine() {
var_dump(func_get_args());
}
2013-12-08 19:52:14 +00:00
function test($x, $y = 0) {
2013-11-22 17:27:55 +00:00
$var = $x + 1;
2013-11-17 13:59:21 +00:00
$var += 2;
$var <<= 3;
2013-11-22 17:27:55 +00:00
$foo = function () {
echo "bar!\n";
};
2013-11-17 13:59:21 +00:00
$foo();
yield $var;
2013-11-17 13:59:21 +00:00
}
2013-11-13 09:17:58 +00:00
$dbg = new phpdbg();
2013-11-12 15:10:29 +00:00
2013-11-13 09:17:58 +00:00
var_dump(
2013-12-20 12:56:21 +00:00
$dbg->isGreat("PHP Rocks!!"));
2013-11-17 13:59:21 +00:00
2013-12-08 19:52:14 +00:00
foreach (test(1,2) as $gen)
2013-11-18 10:32:33 +00:00
continue;
2013-11-17 13:59:21 +00:00
echo "it works!\n";
if (isset($dump))
var_dump($_SERVER);
2013-11-20 14:21:17 +00:00
2013-11-20 18:52:34 +00:00
function phpdbg_test_ob()
2013-11-20 14:21:17 +00:00
{
echo 'Start';
ob_start();
echo 'Hello';
$b = ob_get_clean();
echo 'End';
echo $b;
}
2013-11-20 18:52:34 +00:00
$array = [
1,
2,
[3, 4],
[5, 6],
];
$array[] = 7;
array_walk($array, function (&$item) {
if (is_array($item))
$item[0] += 2;
else
$item -= 1;
});
class testClass {
public $a = 2;
protected $b = [1, 3];
private $c = 7;
}
$obj = new testClass;
$test = $obj->a;
$obj->a += 2;
$test -= 2;
unset($obj);