<?php
class Logger{
public static function log(){
echo 'fuck';
}
}
class Test{
protected $logger;
public function setLogger($logger){
$this->logger = $logger;
}
public function fire(){
$this->logger->log();
}
}
$test = new Test();
$test->setLogger(Logger);
$test->fire();
Fatal error: Uncaught Error: Undefined constant "Logger" in /in/tcRfq:20
Stack trace:
#0 {main}
thrown in /in/tcRfq on line 20
Process exited with code 255.
Warning: Use of undefined constant Logger - assumed 'Logger' (this will throw an Error in a future version of PHP) in /in/tcRfq on line 20
Fatal error: Uncaught Error: Call to a member function log() on string in /in/tcRfq:15
Stack trace:
#0 /in/tcRfq(21): Test->fire()
#1 {main}
thrown in /in/tcRfq on line 15
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33
Notice: Use of undefined constant Logger - assumed 'Logger' in /in/tcRfq on line 20
Fatal error: Uncaught Error: Call to a member function log() on string in /in/tcRfq:15
Stack trace:
#0 /in/tcRfq(21): Test->fire()
#1 {main}
thrown in /in/tcRfq on line 15
Process exited with code 255.
Output for 5.6.7 - 5.6.28
Notice: Use of undefined constant Logger - assumed 'Logger' in /in/tcRfq on line 20
Fatal error: Call to a member function log() on string in /in/tcRfq on line 15
Process exited with code 255.
Notice: Use of undefined constant Logger - assumed 'Logger' in /in/tcRfq on line 20
Fatal error: Call to a member function log() on a non-object in /in/tcRfq on line 15
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/tcRfq on line 3
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/tcRfq on line 3
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/tcRfq on line 3
Process exited with code 255.