3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class MyClass { const CONSTANT = 'constant value'; function showConstant() { echo self::CONSTANT . "\n"; } } echo MyClass::CONSTANT . "\n"; $classname = "MyClass"; echo $classname::CONSTANT . "\n"; // As of PHP 5.3.0 class B { function __construct() { $this->myclass = new MyClass(); $this->myclass->showConstant(); echo $this->myclass::CONSTANT; // <--------- from PHP 7 on } } $b = new B ?>
based on YmaHq
Output for 7.0.0 - 7.2.0
constant value constant value constant value constant value
Output for 5.4.9 - 5.6.28
Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM), expecting ',' or ';' in /in/FPBIL on line 22
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting ',' or ';' in /in/FPBIL on line 22
Process exited with code 255.