@ 2018-07-19T14:13:16Z <?php
Class World {
public $greeting;
public $rand; // no value
private $priv;
public function __construct() {
$this->greeting = 'Hello';
}
}
$w = new World();
$wr = (array) $w;
list($greet_exists, $greet_isset_o, $greet_isset_a, $greet_a_e,$greet_empty) = [
json_encode(property_exists($w,'greeting')), json_encode(isset($w->greeting)),
json_encode(isset($wr['greeting'])), json_encode(array_key_exists('greeting', $wr)), json_encode(empty($w->greeting))
];
echo
"Greeting: {$wr['greeting']}; Exists: $greet_exists; Is prop set: $greet_isset_o; Is index set: $greet_isset_a; Array index: $greet_a_e; Empty: $greet_empty".PHP_EOL;
list($rand_exists,$rand_isset_o,$rand_isset_a,$rand_a_e,$rand_empty) = [
json_encode(property_exists($w,'rand')),json_encode(isset($w->rand)),
json_encode(isset($wr['rand'])),json_encode(array_key_exists('rand', $wr)), json_encode(empty($w->rand))
];
echo "Random: {$wr['rand']}; Exists: $rand_exists; Is prop set: $rand_isset_o; Is index set: $rand_isset_a; Array index: $rand_a_e; Empty: $rand_empty".PHP_EOL;
list($priv_exists,$priv_isset_o,$priv_isset_a,$priv_a_e,$priv_empty) = [
json_encode(property_exists($w,'priv')),json_encode(isset($w->priv)),
json_encode(isset($wr['priv'])),json_encode(array_key_exists('priv', $wr)), json_encode(empty($w->priv))
];
echo "Private: {$wr['priv']}; Exists: $priv_exists; Is prop set: $priv_isset_o; Is index set: $priv_isset_a; Array index: $priv_a_e; Empty: $priv_empty".PHP_EOL;
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.0.0 - 8.0.30 , 8.1.0 - 8.1.33 , 8.2.0 - 8.2.29 , 8.3.0 - 8.3.25 , 8.4.1 - 8.4.13 Greeting: Hello; Exists: true; Is prop set: true; Is index set: true; Array index: true; Empty: false
Random: ; Exists: true; Is prop set: false; Is index set: false; Array index: true; Empty: true
Warning: Undefined array key "priv" in /in/1hLkj on line 31
Private: ; Exists: true; Is prop set: false; Is index set: false; Array index: false; Empty: true
Output for 7.1.0 - 7.1.25 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.31 , 7.4.0 - 7.4.33 Greeting: Hello; Exists: true; Is prop set: true; Is index set: true; Array index: true; Empty: false
Random: ; Exists: true; Is prop set: false; Is index set: false; Array index: true; Empty: true
Notice: Undefined index: priv in /in/1hLkj on line 31
Private: ; Exists: true; Is prop set: false; Is index set: false; Array index: false; Empty: true
Output for 7.3.32 - 7.3.33 Greeting: Hello; Exists: true; Is prop set: true; Is index set: true; Array index: true; Empty: false
Random: ; Exists: true; Is prop set: false; Is index set: false; Array index: true; Empty: true
Private: ; Exists: true; Is prop set: false; Is index set: false; Array index: false; Empty: true
preferences:dark mode live preview ace vim emacs key bindings
103.51 ms | 409 KiB | 5 Q