3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class MyQuery{ public function query() { die('callable called'); } } class QueryHandler { public $query; public function setQuery(callable $query) { echo "checkpoint 1 reached"."\n"; $this->query = $query; } public function runQuery(){ $this->$query(); echo "end (should not show)"."\n"; } } echo "start"."\n"; $myQuery = new MyQuery; $queryHandler = new QueryHandler; $queryHandler->setQuery($myQuery->query); $queryHandler->runQuery();
based on bMqOq
Output for 7.0.0 - 7.2.0
start Notice: Undefined property: MyQuery::$query in /in/9TgDG on line 37 Fatal error: Uncaught TypeError: Argument 1 passed to QueryHandler::setQuery() must be callable, null given, called in /in/9TgDG on line 37 and defined in /in/9TgDG:19 Stack trace: #0 /in/9TgDG(37): QueryHandler->setQuery(NULL) #1 {main} thrown in /in/9TgDG on line 19
Process exited with code 255.
Output for 5.4.2 - 5.6.28
start Notice: Undefined property: MyQuery::$query in /in/9TgDG on line 37 Catchable fatal error: Argument 1 passed to QueryHandler::setQuery() must be callable, null given, called in /in/9TgDG on line 37 and defined in /in/9TgDG on line 19
Process exited with code 255.
Output for 5.3.18 - 5.3.29
start Notice: Undefined property: MyQuery::$query in /in/9TgDG on line 37 Catchable fatal error: Argument 1 passed to QueryHandler::setQuery() must be an instance of callable, null given, called in /in/9TgDG on line 37 and defined in /in/9TgDG on line 19
Process exited with code 255.