<?php
class Dad
{
protected $name;
protected $surname;
public function __consruct(string $name, string $surname)
{
$this->name = $name;
$this->surname = $surname;
}
public function run()
{
echo 'I run fast';
}
protected function drive()
{
echo 'I drive a car';
}
}
class Son extends Dad
{
protected function goToSchool()
{
echo 'I go to school';
}
public function whatIsMyName()
{
echo $this->name;
}
}
$son = new Son('Nick', 'Long');
$son->whatIsMyName();
$son->drive();
Fatal error: Uncaught Error: Call to protected method Dad::drive() from global scope in /in/qEX7T:40
Stack trace:
#0 {main}
thrown in /in/qEX7T on line 40
Process exited with code 255.
Fatal error: Uncaught Error: Call to protected method Dad::drive() from context '' in /in/qEX7T:40
Stack trace:
#0 {main}
thrown in /in/qEX7T on line 40
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Fatal error: Call to protected method Dad::drive() from context '' in /in/qEX7T on line 40
Process exited with code 255.