3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php abstract class HiddenFactory { protected function __construct() { } protected static function create() { return new static(); } } class B extends HiddenFactory {} class A extends HiddenFactory { public static function createB() { return B::create(); } } $b = A::createB(); echo get_class($b); B::create();
Output for 7.0.0 - 7.1.0
B Fatal error: Uncaught Error: Call to protected method HiddenFactory::create() from context '' in /in/PgWEB:32 Stack trace: #0 {main} thrown in /in/PgWEB on line 32
Process exited with code 255.
Output for 5.3.0 - 5.6.28
B Fatal error: Call to protected method HiddenFactory::create() from context '' in /in/PgWEB on line 32
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_STATIC, expecting T_STRING or T_VARIABLE or '$' in /in/PgWEB on line 12
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STATIC, expecting T_STRING or T_VARIABLE or '$' in /in/PgWEB on line 12
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CLASS in /in/PgWEB on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_CLASS in /in/PgWEB on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/PgWEB on line 3
Process exited with code 255.