3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait TaxTools { function calculateтax ( $price ) { return self::prop . $price ; } } abstract class Alert{ const prop = 'value__'; abstract function limpopo(); } class Alert2 extends Alert{ use TaxTools; public function limpopo(){ // return self::$foo; return self::foo; } } $obj = new Alert2; echo $obj->calculateтax(8); //value__8 echo '<br>'; echo $obj::calculateтax(8); //value__8 echo '<br>'; echo $obj::limpopo(); //Fatal error: Undefined class constant 'foo'
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
value__8<br> Fatal error: Uncaught Error: Non-static method Alert2::calculateтax() cannot be called statically in /in/Gg10q:28 Stack trace: #0 {main} thrown in /in/Gg10q on line 28
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33
value__8<br> Deprecated: Non-static method Alert2::calculateтax() should not be called statically in /in/Gg10q on line 28 value__8<br> Deprecated: Non-static method Alert2::limpopo() should not be called statically in /in/Gg10q on line 31 Fatal error: Uncaught Error: Undefined class constant 'foo' in /in/Gg10q:18 Stack trace: #0 /in/Gg10q(31): Alert2::limpopo() #1 {main} thrown in /in/Gg10q on line 18
Process exited with code 255.
Output for 7.3.32 - 7.3.33
value__8<br>value__8<br> Fatal error: Uncaught Error: Undefined class constant 'foo' in /in/Gg10q:18 Stack trace: #0 /in/Gg10q(31): Alert2::limpopo() #1 {main} thrown in /in/Gg10q on line 18
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
value__8<br> Strict Standards: Non-static method Alert2::calculateтax() should not be called statically in /in/Gg10q on line 28 value__8<br> Strict Standards: Non-static method Alert2::limpopo() should not be called statically in /in/Gg10q on line 31 Fatal error: Undefined class constant 'foo' in /in/Gg10q on line 18
Process exited with code 255.

preferences:
162.64 ms | 402 KiB | 183 Q