3v4l.org

run code in 300+ PHP versions simultaneously
<?php class class1 { protected $prop; public function __construct($prop) { $this->prop = $prop; } public function getThing($arg) { assert('$arg->isValid();'); $this->prop->method(); } } class class2 { public function method() { echo "here\n"; } } class class3 { public function isValid() { return false; } } $tmp = new class1(new class2()); $tmp->getThing(new class3());
Output for 8.0.0 - 8.0.22, 8.1.0 - 8.1.9
here
Output for 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.30
Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/7cQNm on line 7 Warning: assert(): Assertion "$arg->isValid();" failed in /in/7cQNm on line 7 here
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.3.32 - 7.3.33
Warning: assert(): Assertion "$arg->isValid();" failed in /in/7cQNm on line 7 here
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/7cQNm on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/7cQNm on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/7cQNm on line 4
Process exited with code 255.

preferences:
74.43 ms | 422 KiB | 13 Q