<?php
phpversion() >= "7.0.0" or die();
class FooBar {
private $x;
public function __construct() {
var_dump($this);
echo "Let's remove a property!", PHP_EOL;
unset($this->x);
var_dump($this);
echo "Let's add a property!", PHP_EOL;
$this->x = 2;
var_dump($this);
echo "Where did the private come from?", PHP_EOL;
}
}
$foobar = new Foobar;
object(FooBar)#1 (1) {
["x":"FooBar":private]=>
NULL
}
Let's remove a property!
object(FooBar)#1 (0) {
}
Let's add a property!
object(FooBar)#1 (1) {
["x":"FooBar":private]=>
int(2)
}
Where did the private come from?
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/hfUIS on line 6
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/hfUIS on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/hfUIS on line 6
Process exited with code 255.