<?php
abstract class Foo{
protected function bar(){
echo 'Foo', PHP_EOL;
var_dump($this);
return $this;
}
}
class Bar extends Foo{
public function foo(){
echo 'Bar', PHP_EOL;
var_dump($this);
// this should hold Bar instance and not Foo's
$barClassInstance = $this->bar();
var_dump($barClassInstance);
}
}
$bar = new Bar();
$bar->foo();
Bar
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/b73bt on line 13
PHP_EOLobject(Bar)#1 (0) {
}
Foo
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/b73bt on line 5
PHP_EOLobject(Bar)#1 (0) {
}
object(Bar)#1 (0) {
}
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CLASS in /in/b73bt on line 3
Process exited with code 255.