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