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; } } class MonopolyMoney extends Money { } $a = new Money(1); $b = new MonopolyMoney(1); var_dump($a->equals($b)); echo $a->amount === 1; print $a->amount === 1;
based on diMZH
Output for 7.0.0 - 7.3.0rc4
bool(true) Fatal error: Uncaught Error: Cannot access private property Money::$amount in /in/Nh6lf:27 Stack trace: #0 {main} thrown in /in/Nh6lf on line 27
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/Nh6lf on line 27
Process exited with code 255.