<?php
class NoIsset
{
public $data;
public function __construct(array $data)
{
$this->data = $data;
}
public function __get($name)
{
return $this->data[$name];
}
}
class HasIsset extends NoIsset
{
public function __isset($name)
{
return isset($this->data[$name]);
}
}
$data = array('one' => 1, 'two' => 2, 'three' => 3);
$no_isset = new NoIsset($data);
$has_isset = new HasIsset($data);
if (empty($no_isset->one))
echo "NoIsset doesn't have one\n";
else
echo "NoIsset has one\n";
if (empty($has_isset->one))
echo "HasIsset doesn't have one\n";
else
echo "HasIsset has one\n";
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/LvJO0 on line 7
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/LvJO0 on line 5
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/LvJO0 on line 5
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/LvJO0 on line 5
Process exited with code 255.