3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Money { private $amount; public function __construct($amount) { $this->amount = $amount; } public function equals(Money $otherMoney) { return $this->amount === $otherMoney->amount; } } $a = new Money(1); $b = new Money(1); var_dump($a->equals($b)); echo $a->amount === 1;
based on fge4a
Output for 7.0.0 - 7.2.6
bool(true) Fatal error: Uncaught Error: Cannot access private property Money::$amount in /in/5Jeov:23 Stack trace: #0 {main} thrown in /in/5Jeov on line 23
Process exited with code 255.
Output for 5.3.20 - 5.6.28
bool(true) Fatal error: Cannot access private property Money::$amount in /in/5Jeov on line 23
Process exited with code 255.