- Output for 5.4.1 - 5.4.45, 5.5.24 - 5.5.30, 5.6.8 - 5.6.14
- Parse error: syntax error, unexpected '$extObject' (T_VARIABLE), expecting function (T_FUNCTION) in /in/E7qCW on line 48
Process exited with code 255.
<?php
class namedClass{
protected $prop;
public function __construct($value){
$this->prop = $value;
}
public function returnProperty($propName){
if( !empty($this->$propName) ){
return $this->$prop;
}else{
return null;
}
}
}
$standardObject = new namedCLass('The named class');
echo $standardObject->returnProperty('prop')."\n";
class namedExtension extends namedClass{
public function returnProperty($propName){
if( !empty($this->$propName) ){
return $this->$prop.' from standard extenstion';
}else{
return null;
}
}
$extObject = new namedExtension('The named extension');
echo $extObject->returnProperty('prop')."\n";
$anonObj = new class('The anonymous class') extends namedClass{
public function returnProperty($propName){
if( !empty($this->$propName) ){
return $this->$prop.' from anonymous class';
}else{
return null;
}
}
};
echo $newObj->returnProperty();