3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Post { const TABLE = 'posts'; const TYPE = 'post'; static public function all() { $select = "SELECT * FROM `%s` WHERE `type` = '%s'\n"; echo sprintf($select, self::TABLE, self::TYPE); } } Post::all(); class Comment extends Post { const TYPE = 'comment'; } Comment::all(); echo "===\n'; class PostA { const TABLE = 'posts'; const TYPE = 'post'; static public function all() { $select = "SELECT * FROM `%s` WHERE `type` = '%s'\n"; echo sprintf($select, static::TABLE, static::TYPE); } } PostA::all(); // SELECT * FROM `posts` WHERE `type` = 'post' class CommentA extends PostA { const TYPE = 'comment'; } CommentA::all();
based on MXPhH
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.1.7
Parse error: syntax error, unexpected 'SELECT' (T_STRING), expecting ',' or ';' in /in/2a1u3 on line 29
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught Error: syntax error, unexpected T_STRING, expecting ',' or ';' in /in/2a1u3:29 Stack trace: #0 {main}
Process exited with code 255.