2011-04-10 14:08:20 +00:00
|
|
|
<?php
|
2013-07-19 05:03:07 +00:00
|
|
|
#if PHP_VERSION >= 500
|
|
|
|
# define PublicMethod public
|
|
|
|
#else
|
2013-07-19 06:50:48 +00:00
|
|
|
# define ClassName classname
|
2013-07-19 05:03:07 +00:00
|
|
|
# define PublicMethod
|
|
|
|
# define abstract
|
|
|
|
# define innerIf_ innerif_
|
|
|
|
# define emptySwitch emptyswitch
|
|
|
|
# define defaultSwitch defaultswitch
|
|
|
|
#endif
|
|
|
|
#if PHP_VERSION >= 520
|
|
|
|
#else
|
|
|
|
# define __callStatic __callstatic
|
|
|
|
# define __toString __tostring
|
|
|
|
#endif
|
|
|
|
#if PHP_VERSION >= 530
|
2011-04-10 14:08:20 +00:00
|
|
|
|
2013-07-16 03:24:01 +00:00
|
|
|
namespace ns;
|
2013-07-19 05:03:07 +00:00
|
|
|
#endif
|
2013-07-16 03:24:01 +00:00
|
|
|
|
2013-07-19 06:50:48 +00:00
|
|
|
abstract class ClassName
|
2013-07-16 03:24:01 +00:00
|
|
|
{
|
2013-07-19 05:03:07 +00:00
|
|
|
#if PHP_VERSION >= 500
|
2013-07-16 03:24:01 +00:00
|
|
|
const CONST_VALUE = 'A constant value';
|
2014-09-11 17:20:03 +00:00
|
|
|
const file = __FILE__;
|
|
|
|
#if PHP_VERSION >= 530
|
|
|
|
const dir = __DIR__;
|
|
|
|
#endif
|
2013-07-16 03:24:01 +00:00
|
|
|
|
|
|
|
/** doc */
|
|
|
|
static public $static = array(
|
2013-08-12 09:25:57 +00:00
|
|
|
0 => array('array'),
|
|
|
|
1 => 'str',
|
|
|
|
CONST_VALUE => CONST_VALUE
|
2013-07-16 03:24:01 +00:00
|
|
|
);
|
2013-11-06 15:45:19 +00:00
|
|
|
static public $classProp;
|
2013-09-16 15:48:48 +00:00
|
|
|
static public $static_const1 = CONST_VALUE;
|
|
|
|
static public $static_const2 = self::CONST_VALUE;
|
|
|
|
static public $static_const3 = ClassName::CONST_VALUE;
|
|
|
|
static public $static_const4 = array(CONST_VALUE => 'test');
|
|
|
|
static public $static_const5 = array(self::CONST_VALUE => 'test');
|
|
|
|
static public $static_const6 = array(ClassName::CONST_VALUE => 'test');
|
|
|
|
static public $static_const7 = array('test' => CONST_VALUE);
|
|
|
|
static public $static_const8 = array('test' => self::CONST_VALUE);
|
|
|
|
static public $static_const9 = array('test' => ClassName::CONST_VALUE);
|
|
|
|
static public $static_const10 = array(CONST_VALUE => CONST_VALUE);
|
|
|
|
static public $static_const11 = array(self::CONST_VALUE => self::CONST_VALUE);
|
|
|
|
static public $static_const12 = array(ClassName::CONST_VALUE => ClassName::CONST_VALUE);
|
2014-05-27 15:54:45 +00:00
|
|
|
#if PHP_VERSION >= 560
|
2014-05-27 15:48:37 +00:00
|
|
|
static public $ast_binop = ClassName::CONST_VALUE + ClassName::CONST_VALUE;
|
|
|
|
static public $ast_and = ClassName::CONST_VALUE && 1;
|
|
|
|
static public $ast_or = ClassName::CONST_VALUE || 2;
|
|
|
|
static public $ast_select = ClassName::CONST_VALUE ? a : b;
|
|
|
|
static public $ast_unaryPlus = +ClassName::CONST_VALUE;
|
|
|
|
static public $ast_unaryMinus = -ClassName::CONST_VALUE;
|
2014-05-27 15:54:45 +00:00
|
|
|
#endif
|
2013-07-16 03:24:01 +00:00
|
|
|
/** doc */
|
|
|
|
static public $public_static = array(2, 'str');
|
|
|
|
/** doc */
|
|
|
|
static private $private_static = array(2, 'str');
|
2013-09-16 15:07:37 +00:00
|
|
|
static private $private_static2 = array(self::CONST_VALUE => self::CONST_VALUE);
|
2013-07-16 03:24:01 +00:00
|
|
|
/** doc */
|
|
|
|
static protected $protected_static = array(2, 'str');
|
2013-09-16 15:07:37 +00:00
|
|
|
static protected $protected_static2 = array(self::CONST_VALUE => self::CONST_VALUE);
|
2013-07-16 03:24:01 +00:00
|
|
|
/** doc */
|
|
|
|
public $property = array(
|
|
|
|
array('array'),
|
|
|
|
'str'
|
|
|
|
);
|
|
|
|
/** doc */
|
|
|
|
public $public_property = array(2, 'str');
|
|
|
|
/** doc */
|
|
|
|
private $private_property = array(2, 'str');
|
|
|
|
/** doc */
|
|
|
|
protected $protected_property = array(2, 'str');
|
2013-11-06 15:45:19 +00:00
|
|
|
public $array = array();
|
2013-07-19 05:03:07 +00:00
|
|
|
#else
|
|
|
|
var $property = array(
|
|
|
|
array('array'),
|
|
|
|
'str'
|
|
|
|
);
|
|
|
|
#endif
|
2013-07-16 03:24:01 +00:00
|
|
|
|
2013-07-19 05:03:07 +00:00
|
|
|
#if PHP_VERSION >= 500
|
2013-07-16 03:24:01 +00:00
|
|
|
/** doc */
|
2013-07-19 05:03:07 +00:00
|
|
|
#endif
|
2013-11-06 15:45:19 +00:00
|
|
|
PublicMethod function f1()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PublicMethod function f2()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PublicMethod function __construct($arg1, $arg2)
|
2013-07-16 03:24:01 +00:00
|
|
|
{
|
2013-08-12 09:25:57 +00:00
|
|
|
static $array = array(
|
|
|
|
0 => array('array'),
|
|
|
|
1 => 'str',
|
|
|
|
CONST_VALUE => CONST_VALUE
|
|
|
|
);
|
2013-11-06 15:45:19 +00:00
|
|
|
static $static = 1;
|
2013-08-12 09:25:57 +00:00
|
|
|
static $str = 'string';
|
2013-07-16 03:24:01 +00:00
|
|
|
echo CONST_VALUE;
|
2013-07-19 05:03:07 +00:00
|
|
|
#if PHP_VERSION >= 500
|
2013-07-16 03:24:01 +00:00
|
|
|
echo ClassName::CONST_VALUE;
|
|
|
|
empty(ClassName::$classProp);
|
|
|
|
isset(ClassName::$classProp);
|
|
|
|
ClassName::$classProp = 1;
|
|
|
|
echo ClassName::$classProp;
|
2013-07-19 05:03:07 +00:00
|
|
|
#endif
|
2013-11-06 15:45:19 +00:00
|
|
|
$object = $this;
|
|
|
|
$object->a = 1;
|
|
|
|
$object->b = 2;
|
|
|
|
$object->prop = 'prop';
|
|
|
|
empty($object->objProp);
|
|
|
|
isset($object->objProp);
|
2013-07-19 05:03:07 +00:00
|
|
|
#if PHP_VERSION >= 500
|
2013-11-06 15:45:19 +00:00
|
|
|
unset($object->objProp);
|
2013-07-19 05:03:07 +00:00
|
|
|
#endif
|
2013-11-06 15:45:19 +00:00
|
|
|
$object->objProp = 1;
|
|
|
|
echo $object->objProp;
|
2013-07-16 03:24:01 +00:00
|
|
|
empty($this->thisProp);
|
|
|
|
isset($this->thisProp);
|
2013-07-19 05:03:07 +00:00
|
|
|
#if PHP_VERSION >= 500
|
2013-07-16 03:24:01 +00:00
|
|
|
unset($this->thisProp);
|
2013-07-19 05:03:07 +00:00
|
|
|
#endif
|
2013-07-16 03:24:01 +00:00
|
|
|
$this->thisProp = 1;
|
|
|
|
echo $this->thisProp;
|
2013-07-19 05:03:07 +00:00
|
|
|
#if PHP_VERSION >= 500
|
2013-07-16 03:24:01 +00:00
|
|
|
unset($array['index']->valueProp);
|
2013-07-19 05:03:07 +00:00
|
|
|
#endif
|
2013-11-06 15:45:19 +00:00
|
|
|
unset($object->array['index']);
|
2013-07-16 03:24:01 +00:00
|
|
|
unset($this->array['index']);
|
|
|
|
empty($_GET['get']);
|
|
|
|
isset($_GET['get']);
|
|
|
|
unset($_GET['get']);
|
|
|
|
$_GET['get'] = 1;
|
|
|
|
echo $_GET['get'];
|
|
|
|
isset($GLOBALS['global']);
|
|
|
|
empty($GLOBALS['global']);
|
|
|
|
unset($GLOBALS['global']);
|
|
|
|
$GLOBALS['global'] = 1;
|
|
|
|
echo $GLOBALS['global'];
|
|
|
|
empty($array['index']);
|
|
|
|
isset($array['index']);
|
|
|
|
unset($array['index']);
|
|
|
|
$array['index'] = 1;
|
|
|
|
echo $array['index'];
|
|
|
|
empty($array['index']->indexProp);
|
|
|
|
isset($array['index']->indexProp);
|
2013-07-19 05:03:07 +00:00
|
|
|
#if PHP_VERSION >= 500
|
2013-07-16 03:24:01 +00:00
|
|
|
unset($array['index']->indexProp);
|
2013-07-19 05:03:07 +00:00
|
|
|
#endif
|
2013-11-06 15:45:19 +00:00
|
|
|
$array['index'] = $object;
|
2015-06-29 05:16:17 +00:00
|
|
|
$array['index'] .= $object;
|
2013-07-16 03:24:01 +00:00
|
|
|
$array['index']->indexProp = 1;
|
|
|
|
echo $array['index']->indexProp;
|
2013-11-06 15:45:19 +00:00
|
|
|
$GLOBALS['var'] = $object;
|
2013-07-16 03:24:01 +00:00
|
|
|
empty($GLOBALS['var']->indexProp);
|
|
|
|
isset($GLOBALS['var']->indexProp);
|
2013-07-19 05:03:07 +00:00
|
|
|
#if PHP_VERSION >= 500
|
2013-07-16 03:24:01 +00:00
|
|
|
unset($GLOBALS['var']->indexProp);
|
2013-07-19 05:03:07 +00:00
|
|
|
#endif
|
2013-07-16 03:24:01 +00:00
|
|
|
$GLOBALS['var']->indexProp = 1;
|
|
|
|
echo $GLOBALS['var']->indexProp;
|
2013-11-06 15:45:19 +00:00
|
|
|
|
|
|
|
if (0) {
|
|
|
|
ClassName::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
$method = 'method';
|
|
|
|
ClassName::$method();
|
2013-07-19 05:03:07 +00:00
|
|
|
echo __CLASS__;
|
|
|
|
echo __METHOD__;
|
|
|
|
echo __FUNCTION__;
|
2013-11-06 15:45:19 +00:00
|
|
|
$this->method();
|
2014-05-27 04:53:19 +00:00
|
|
|
|
2013-07-19 05:03:07 +00:00
|
|
|
#if PHP_VERSION >= 500
|
2013-11-06 15:45:19 +00:00
|
|
|
try {
|
2015-06-25 04:15:04 +00:00
|
|
|
throw new Exception();
|
|
|
|
new Exception();
|
2013-11-06 15:45:19 +00:00
|
|
|
}
|
2015-06-25 04:15:04 +00:00
|
|
|
catch (Exception $e) {
|
2013-11-06 15:45:19 +00:00
|
|
|
}
|
2013-07-19 05:03:07 +00:00
|
|
|
#endif
|
2013-11-06 15:45:19 +00:00
|
|
|
|
|
|
|
$a = 1;
|
|
|
|
$b = $c = 2;
|
|
|
|
$a = $b + $c;
|
|
|
|
$a = $b + 1;
|
|
|
|
$a = 1 + $b;
|
|
|
|
$a = $b - $c;
|
|
|
|
$a = $b * $c;
|
|
|
|
$a = $b / $c;
|
|
|
|
$a = $b % $c;
|
|
|
|
$a = $b . $c;
|
|
|
|
$a = $b = $c;
|
|
|
|
$a = $b & $c;
|
|
|
|
$a = $b | $c;
|
|
|
|
$a = $b ^ $c;
|
|
|
|
$a = ~$b;
|
|
|
|
$a = -$b;
|
|
|
|
$a = +$b;
|
|
|
|
$a = $b >> $c;
|
|
|
|
$a = $b >> $c;
|
|
|
|
$a = $b == $c;
|
|
|
|
$a = $b === $c;
|
|
|
|
$a = $b != $c;
|
|
|
|
$a = $b < $c;
|
|
|
|
$a = $b <= $c;
|
|
|
|
$a = $b <= $c;
|
|
|
|
$a = $b++;
|
|
|
|
$a = ++$b;
|
|
|
|
$a = $object->b++;
|
|
|
|
$a = ++$object->b;
|
|
|
|
$a = $b--;
|
|
|
|
$a = --$b;
|
|
|
|
$a = $object->b--;
|
|
|
|
$a = --$object->b;
|
|
|
|
$a = !$b;
|
|
|
|
$a = $b === $c;
|
|
|
|
$a = $b !== $c;
|
|
|
|
$a = $b << 2;
|
|
|
|
$a = $b >> 3;
|
|
|
|
$a += $b;
|
|
|
|
$a -= $b;
|
|
|
|
$a *= $b;
|
|
|
|
$a /= $b;
|
|
|
|
$a <<= $b;
|
|
|
|
$a >>= $b;
|
|
|
|
$a &= $b;
|
|
|
|
$a |= $b;
|
|
|
|
$a .= $b;
|
|
|
|
$a %= $b;
|
|
|
|
$a ^= $b;
|
|
|
|
$a = 'a' . 'b';
|
|
|
|
$a = 'a' . 'abc';
|
2014-09-11 17:09:30 +00:00
|
|
|
$a = __FILE__;
|
|
|
|
#if PHP_VERSION >= 530
|
|
|
|
$a = __DIR__;
|
|
|
|
#endif
|
|
|
|
$a = 'a' . __FILE__;
|
|
|
|
#if PHP_VERSION >= 530
|
|
|
|
$a = 'a' . __DIR__;
|
|
|
|
#endif
|
2013-11-06 15:45:19 +00:00
|
|
|
@f1();
|
|
|
|
print('1');
|
|
|
|
$array = array('index' => 1);
|
|
|
|
$a = $array['index'];
|
|
|
|
$a = $object->prop;
|
|
|
|
$a = $this->prop;
|
|
|
|
$array['index'] = 1;
|
|
|
|
$object->prop = 1;
|
|
|
|
$this->prop = 1;
|
|
|
|
$a = isset($b);
|
|
|
|
$a = empty($b);
|
|
|
|
unset($b);
|
|
|
|
$b = 1;
|
|
|
|
$a = isset($array['index']);
|
|
|
|
$a = empty($array['index']);
|
|
|
|
unset($array['index']);
|
|
|
|
$a = isset($object->prop);
|
|
|
|
$a = empty($object->prop);
|
|
|
|
#if PHP_VERSION >= 500
|
|
|
|
unset($object->prop);
|
|
|
|
#endif
|
|
|
|
$a = isset($this->prop);
|
|
|
|
$a = empty($this->prop);
|
|
|
|
#if PHP_VERSION >= 500
|
|
|
|
unset($this->prop);
|
|
|
|
$a = isset(ClassName::$prop);
|
|
|
|
$a = empty(ClassName::$prop);
|
|
|
|
#endif
|
|
|
|
$a = (int) $b;
|
|
|
|
$a = (double) $b;
|
|
|
|
$a = (string) $b;
|
|
|
|
$a = (array) $b;
|
|
|
|
$a = (object) $b;
|
|
|
|
$a = (bool) $b;
|
|
|
|
$a = (unset) $b;
|
|
|
|
$a = (array) $b;
|
|
|
|
$a = (object) $b;
|
|
|
|
$a = ($b ? $c : $d);
|
|
|
|
$a = (f1() ? f2() : f3());
|
|
|
|
($a = $b) xor $c;
|
|
|
|
($a = $b) and $c;
|
|
|
|
($a = $b) or $c;
|
|
|
|
$a = $b && $c;
|
|
|
|
$a = $b || $c;
|
|
|
|
#if PHP_VERSION >= 530
|
2015-06-25 04:13:17 +00:00
|
|
|
echo $this::CONST_VALUE;
|
|
|
|
echo $object::CONST_VALUE;
|
|
|
|
echo CONST_VALUE;
|
2013-11-06 15:45:19 +00:00
|
|
|
$this::method();
|
|
|
|
$object::method();
|
|
|
|
$a = $b ?: $d;
|
|
|
|
$a = ($b ?: $d) + $c;
|
|
|
|
$a = f1() ?: f2();
|
|
|
|
$a = ClassName::f1() ?: ClassName::f2();
|
|
|
|
$a = ($b ? $c : $d);
|
|
|
|
$a = ($b ? $c : $d) + $c;
|
|
|
|
$a = (f1() ? f3() : f2());
|
|
|
|
|
|
|
|
if ($b ?: $d) {
|
|
|
|
echo 'if ($b ?: $d)';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (($b ?: $d) + $c) {
|
|
|
|
echo 'if (($b ?: $d) + $c)';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (f1() ?: f2()) {
|
|
|
|
echo 'if (f1() ?: f2())';
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2014-09-11 17:09:30 +00:00
|
|
|
#if PHP_VERSION >= 500
|
2013-11-06 15:45:19 +00:00
|
|
|
|
|
|
|
public function __destruct()
|
|
|
|
{
|
2013-07-16 03:24:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** doc */
|
2013-11-06 15:45:19 +00:00
|
|
|
abstract public function abstractMethod();
|
2013-07-19 05:03:07 +00:00
|
|
|
#endif
|
2013-07-16 03:24:01 +00:00
|
|
|
|
2013-07-19 05:03:07 +00:00
|
|
|
#if PHP_VERSION >= 500
|
2013-07-16 03:24:01 +00:00
|
|
|
/** doc */
|
2013-07-19 05:03:07 +00:00
|
|
|
#endif
|
|
|
|
PublicMethod function method($a = NULL, $b = NULL)
|
2013-07-16 03:24:01 +00:00
|
|
|
{
|
|
|
|
}
|
2013-07-19 05:03:07 +00:00
|
|
|
#if PHP_VERSION >= 500
|
2013-07-16 03:24:01 +00:00
|
|
|
|
|
|
|
/** doc */
|
|
|
|
protected function protectedMethod(ClassName $a, $b = array(
|
|
|
|
array('array')
|
|
|
|
))
|
|
|
|
{
|
|
|
|
$runtimeArray = array('1');
|
|
|
|
$runtimeArray2 = array(
|
|
|
|
'1',
|
|
|
|
array()
|
|
|
|
);
|
|
|
|
$runtimeArray3 = array(
|
|
|
|
'a' => '1',
|
|
|
|
2 => array()
|
|
|
|
);
|
|
|
|
return 'protected';
|
|
|
|
}
|
|
|
|
|
|
|
|
/** doc */
|
|
|
|
private function privateMethod(ClassName $a, $b = NULL)
|
|
|
|
{
|
|
|
|
return 'private';
|
|
|
|
}
|
2013-07-19 05:03:07 +00:00
|
|
|
#endif
|
2013-07-16 03:24:01 +00:00
|
|
|
}
|
2013-07-19 05:03:07 +00:00
|
|
|
#if PHP_VERSION >= 500
|
2013-07-16 03:24:01 +00:00
|
|
|
|
|
|
|
interface IInterface
|
|
|
|
{
|
|
|
|
public function nothing();
|
|
|
|
}
|
2013-07-19 05:03:07 +00:00
|
|
|
#endif
|
2013-07-16 03:24:01 +00:00
|
|
|
|
2013-11-06 15:45:19 +00:00
|
|
|
function f1()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
function f2()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
function f3()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
function generator($f)
|
2013-07-16 03:24:01 +00:00
|
|
|
{
|
|
|
|
echo __FUNCTION__;
|
|
|
|
echo $f;
|
2013-07-19 06:57:49 +00:00
|
|
|
#if PHP_VERSION >= 550
|
2013-07-19 03:52:20 +00:00
|
|
|
|
|
|
|
foreach ($a as $b) {
|
2013-07-19 06:57:49 +00:00
|
|
|
yield $b;
|
2013-07-19 03:52:20 +00:00
|
|
|
}
|
|
|
|
|
2013-07-19 06:57:49 +00:00
|
|
|
yield f1($b);
|
2013-07-19 05:03:07 +00:00
|
|
|
#endif
|
2013-07-16 03:24:01 +00:00
|
|
|
}
|
2013-07-19 05:03:07 +00:00
|
|
|
#if PHP_VERSION >= 500
|
2013-07-16 03:24:01 +00:00
|
|
|
|
|
|
|
final class Child extends ClassName implements IInterface
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
2013-11-06 15:45:19 +00:00
|
|
|
parent::__construct('a', 'b');
|
2013-07-16 03:24:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function __destruct()
|
|
|
|
{
|
|
|
|
parent::__destruct();
|
|
|
|
}
|
|
|
|
|
|
|
|
static public function __callStatic($name, $args)
|
|
|
|
{
|
|
|
|
parent::__callStatic($name, $args);
|
|
|
|
}
|
|
|
|
|
2013-11-06 15:45:19 +00:00
|
|
|
public function abstractMethod()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function nothing()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-07-16 03:24:01 +00:00
|
|
|
public function __toString()
|
|
|
|
{
|
|
|
|
parent::__toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __set($name, $value)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __get($name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __isset($name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __unset($name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __sleep()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __wakeup()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __clone()
|
|
|
|
{
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
}
|
2013-07-19 05:03:07 +00:00
|
|
|
#endif
|
2013-07-16 03:24:01 +00:00
|
|
|
|
2013-11-06 15:45:19 +00:00
|
|
|
define('CONST_VALUE', 'const value');
|
|
|
|
$late = isset($_ENV['LATE']);
|
|
|
|
|
2013-07-16 03:24:01 +00:00
|
|
|
if ($late) {
|
|
|
|
class LateBindingClass
|
|
|
|
{
|
2013-07-19 05:03:07 +00:00
|
|
|
PublicMethod function __construct()
|
2013-07-16 03:24:01 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function lateBindingFunction($arg)
|
|
|
|
{
|
|
|
|
echo 'lateFunction';
|
|
|
|
return new lateBindingFunction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "\r\n";
|
|
|
|
echo "\r";
|
|
|
|
echo "\n";
|
2013-11-06 15:45:19 +00:00
|
|
|
var_dump(array('a' => 'a', 'b' => 'c'), 'b');
|
|
|
|
$object = new Child();
|
|
|
|
$className = 'ns\\Child';
|
2013-07-16 03:24:01 +00:00
|
|
|
$object = new $className();
|
2013-07-19 05:03:07 +00:00
|
|
|
#if PHP_VERSION >= 500
|
2013-11-06 15:45:19 +00:00
|
|
|
$result = $object instanceof Child;
|
2013-07-16 03:24:01 +00:00
|
|
|
$cloned = clone $object;
|
2013-07-19 05:03:07 +00:00
|
|
|
#endif
|
|
|
|
#if PHP_VERSION >= 500
|
2013-07-16 03:24:01 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
try {
|
|
|
|
echo 'outer try 1';
|
|
|
|
|
|
|
|
try {
|
|
|
|
echo 'inner try';
|
|
|
|
}
|
|
|
|
catch (InnerException $e) {
|
|
|
|
echo $e;
|
|
|
|
}
|
2013-07-22 07:20:55 +00:00
|
|
|
catch (InnerException2 $e2) {
|
|
|
|
echo $e2;
|
|
|
|
}
|
2013-07-19 05:03:07 +00:00
|
|
|
#if PHP_VERSION >= 550
|
|
|
|
finally {
|
|
|
|
echo 'inner finally';
|
|
|
|
}
|
|
|
|
#endif
|
2013-07-16 03:24:01 +00:00
|
|
|
|
|
|
|
echo 'outer try 2';
|
|
|
|
}
|
|
|
|
catch (OuterException $e) {
|
|
|
|
echo $e;
|
|
|
|
}
|
2013-07-22 07:20:55 +00:00
|
|
|
catch (OuterException2 $e2) {
|
|
|
|
echo $e2;
|
|
|
|
}
|
2013-07-19 05:03:07 +00:00
|
|
|
#if PHP_VERSION >= 550
|
|
|
|
finally {
|
|
|
|
echo 'outer finally';
|
|
|
|
}
|
|
|
|
#endif
|
2013-07-16 03:24:01 +00:00
|
|
|
} while (0);
|
2013-07-19 05:03:07 +00:00
|
|
|
#endif
|
2013-07-16 03:24:01 +00:00
|
|
|
|
2015-04-18 09:29:00 +00:00
|
|
|
list($a, $b) = array(1, 2);
|
|
|
|
|
2013-11-06 15:45:19 +00:00
|
|
|
if ('if()') {
|
2013-07-16 03:24:01 +00:00
|
|
|
echo 'if';
|
|
|
|
|
2013-11-06 15:45:19 +00:00
|
|
|
if ('innerIf()') {
|
2013-07-16 03:24:01 +00:00
|
|
|
echo 'if innerIf';
|
|
|
|
}
|
|
|
|
}
|
2013-11-06 15:45:19 +00:00
|
|
|
else if ('elseif_()') {
|
2013-07-16 03:24:01 +00:00
|
|
|
echo 'else if';
|
|
|
|
|
2013-11-06 15:45:19 +00:00
|
|
|
if ('innerIf_()') {
|
2013-07-16 03:24:01 +00:00
|
|
|
echo 'if innerIf';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2013-11-06 15:45:19 +00:00
|
|
|
if ('innerIf_()') {
|
2013-07-16 03:24:01 +00:00
|
|
|
echo 'if innerIf';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo 'else';
|
|
|
|
}
|
|
|
|
|
2015-04-18 09:29:00 +00:00
|
|
|
if (!'if(!)') {
|
|
|
|
echo 'if(!)';
|
|
|
|
}
|
|
|
|
|
2013-07-16 03:24:01 +00:00
|
|
|
while (false) {
|
|
|
|
echo 'while';
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
echo 'do/while';
|
|
|
|
} while (false);
|
|
|
|
|
|
|
|
$i = 1;
|
|
|
|
|
|
|
|
for (; $i < 10; ++$i) {
|
|
|
|
echo $i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-11-06 15:45:19 +00:00
|
|
|
$array = array(
|
2014-05-27 04:53:19 +00:00
|
|
|
array('a' => 'b')
|
|
|
|
);
|
|
|
|
|
2013-07-16 03:24:01 +00:00
|
|
|
foreach ($array as $value) {
|
|
|
|
foreach ($value as $key => $value) {
|
|
|
|
echo $key . ' = ' . $value . "\n";
|
|
|
|
break 2;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 15:45:19 +00:00
|
|
|
switch ('$normalSwitch') {
|
2013-07-16 03:24:01 +00:00
|
|
|
case 'case1':
|
|
|
|
echo 'case1';
|
|
|
|
|
2013-11-06 15:45:19 +00:00
|
|
|
switch ('$nestedSwitch') {
|
2013-07-16 03:24:01 +00:00
|
|
|
case 1:
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'case2':
|
|
|
|
echo 'case2';
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2013-11-06 15:45:19 +00:00
|
|
|
switch ('$nestedSwitch') {
|
2013-07-16 03:24:01 +00:00
|
|
|
case 1:
|
|
|
|
}
|
|
|
|
|
|
|
|
echo 'default';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-11-06 15:45:19 +00:00
|
|
|
switch ('$switchWithoutDefault') {
|
2013-07-16 03:24:01 +00:00
|
|
|
case 'case1':
|
|
|
|
echo 'case1';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'case2':
|
|
|
|
echo 'case2';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-11-06 15:45:19 +00:00
|
|
|
switch ('$switchWithMiddleDefault') {
|
2013-07-16 03:24:01 +00:00
|
|
|
case 'case1':
|
|
|
|
echo 'case1';
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
echo 'default';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'case2':
|
|
|
|
echo 'case2';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-11-06 15:45:19 +00:00
|
|
|
switch ('$switchWithInitialDefault') {
|
2013-07-16 03:24:01 +00:00
|
|
|
default:
|
|
|
|
echo 'default';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'case1':
|
|
|
|
echo 'case1';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'case2':
|
|
|
|
echo 'case2';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-11-06 15:45:19 +00:00
|
|
|
switch ('emptySwitch()') {
|
2013-07-16 03:24:01 +00:00
|
|
|
}
|
|
|
|
|
2013-11-06 15:45:19 +00:00
|
|
|
switch ('defaultSwitch()') {
|
2013-07-16 03:24:01 +00:00
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
|
|
|
declare (ticks=1) {
|
|
|
|
echo 1;
|
|
|
|
}
|
|
|
|
|
2013-11-06 15:45:19 +00:00
|
|
|
$a = true;
|
2014-05-27 04:53:19 +00:00
|
|
|
|
2013-11-06 15:45:19 +00:00
|
|
|
while ($a) {
|
2013-07-16 03:24:01 +00:00
|
|
|
declare (ticks=1) {
|
|
|
|
echo 2;
|
|
|
|
}
|
2014-05-27 04:53:19 +00:00
|
|
|
|
2013-11-06 15:45:19 +00:00
|
|
|
$a = false;
|
2013-07-16 03:24:01 +00:00
|
|
|
}
|
|
|
|
|
2014-09-11 17:20:03 +00:00
|
|
|
require 'devel/require.php';
|
|
|
|
require_once 'devel/require_once.php';
|
|
|
|
include 'devel/include.php';
|
|
|
|
include_once 'devel/include_once.php';
|
2013-08-20 02:55:04 +00:00
|
|
|
echo __FILE__;
|
2014-09-11 17:09:30 +00:00
|
|
|
#if PHP_VERSION >= 530
|
|
|
|
echo __DIR__;
|
|
|
|
#endif
|
2013-08-20 02:55:04 +00:00
|
|
|
echo __LINE__;
|
2013-07-19 05:03:07 +00:00
|
|
|
#if PHP_VERSION >= 530
|
2013-07-16 03:24:01 +00:00
|
|
|
echo 'goto a';
|
|
|
|
goto a;
|
|
|
|
|
|
|
|
$i = 1;
|
|
|
|
|
|
|
|
for (; $i <= 2; ++$i) {
|
|
|
|
goto a;
|
|
|
|
}
|
|
|
|
|
|
|
|
a:
|
|
|
|
echo 'label a';
|
|
|
|
echo preg_replace_callback('~-([a-z])~', function($match) {
|
|
|
|
return strtoupper($match[1]);
|
|
|
|
}, 'hello-world');
|
|
|
|
$greet = function($name) {
|
2013-09-16 15:07:37 +00:00
|
|
|
printf('Hello %s' . "\r\n" . '', $name);
|
2013-07-16 03:24:01 +00:00
|
|
|
};
|
|
|
|
$greet('World');
|
|
|
|
$greet('PHP');
|
|
|
|
$total = 0;
|
|
|
|
$tax = 1;
|
|
|
|
$callback = function($quantity, $product) use($tax, &$total) {
|
|
|
|
$tax = 'tax';
|
|
|
|
static $static1 = array(1);
|
|
|
|
static $static2;
|
|
|
|
$tax = 'tax';
|
|
|
|
$tax = --$tax;
|
|
|
|
$pricePerItem = constant('PRICE_' . strtoupper($product));
|
|
|
|
$total += $pricePerItem * $quantity * ($tax + 1);
|
|
|
|
};
|
2013-07-19 05:03:07 +00:00
|
|
|
#endif
|
2013-07-16 03:24:01 +00:00
|
|
|
exit();
|
2015-04-18 09:29:00 +00:00
|
|
|
exit(1);
|
2015-04-24 13:14:08 +00:00
|
|
|
array(eval('array 1'));
|
|
|
|
array();
|
2011-04-14 05:30:54 +00:00
|
|
|
|
2011-04-10 14:08:20 +00:00
|
|
|
?>
|