3v4l.org

run code in 300+ PHP versions simultaneously
<?php @ini_set('display_errors', 'on'); class Configuration { public static function get($param) { return true; } } class Cart { public function getProducts() { return array(1); } } class Context { public $cart; public function __construct() { $this->cart = new Cart(); } public static function getContext() { return new Context(); } } if (Configuration::get('LEGAL_SHIPTAXMETH') && $cart = Context::getContext()->cart && $products = $cart->getProducts() && !empty($products)) { echo "OK"; } /** * The above code snippet fails, because I think the condition is parsed like this: * * Configuration::get('LEGAL_SHIPTAXMETH') && * $cart = (Context::getContext()->cart && $products = $cart->getProducts()) * && !empty($products) * * so $cart is undefined when getProducts is called * */
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $cart in /in/trEeK on line 38 Fatal error: Uncaught Error: Call to a member function getProducts() on null in /in/trEeK:38 Stack trace: #0 {main} thrown in /in/trEeK on line 38
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
54.55 ms | 401 KiB | 8 Q