3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Currency { public $currencyCode; public function __construct($currencyCode) { $this->currencyCode = $currencyCode; } public function equals(Currency $currency) { return $this->currencyCode === $currency->currencyCode; } } class Money { public $amount; public $currency; public function __construct($amount, Currency $currency = null) { $this->currency = $currency ?: new Currency('USD'); } } echo "True/Object comparison with loosy operator (should be true):\r\n"; var_dump(new Money(55) == true); echo "True/Object comparision with strict operator (should be false):\r\n"; var_dump(new Money(55) === true); echo "False/Null comparison with loose operator (should be true):\r\n"; var_dump(null == false); echo "False/Null comparision with strict operator (should be false):\r\n"; var_dump(null === false); // $currency is passed in, $currency == true $revenue = new Money(55, new Currency('GBP')); echo "Short-hand ternary when currency is set (should be true):\r\n"; var_dump($revenue->currency->equals(new Currency('GBP'))); // $currency is null, $currency == false $assets = new Money(55); echo "Short-hand ternary when currency is not set (should be true):\r\n"; var_dump($assets->currency->equals(new Currency('USD')));
Output for git.master, git.master_jit, rfc.property-hooks
True/Object comparison with loosy operator (should be true): bool(true) True/Object comparision with strict operator (should be false): bool(false) False/Null comparison with loose operator (should be true): bool(true) False/Null comparision with strict operator (should be false): bool(false) Short-hand ternary when currency is set (should be true): bool(true) Short-hand ternary when currency is not set (should be true): bool(true)

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:
41.66 ms | 402 KiB | 8 Q