<?php
class classA
{
public $prop1 = "I'm a class property!";
public function setProperty($newval)
{
$this->prop1 = $newval;
}
protected function getProperty()
{
return $this->prop1 . "<br />";
}
}
class classB extends classA
{
public function getProperty()
{
return 'B: ' . $this->prop1 . "<br />";
}
public function callProtected()
{
return $this->getProperty();
}
public function callProtected2()
{
return parent::getProperty();
}
}
$testobj = new classB;
echo $testobj->callProtected();
echo $testobj->callProtected2();
?>
B: I'm a class property!<br />I'm a class property!<br />
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/cTeeF on line 4
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/cTeeF on line 4
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/cTeeF on line 4
Process exited with code 255.