3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* ############################################################################################### #############################classes.php####################################################### ############################################################################################## */ class EmailAddress { private $emailAddress; public function getEmailAddress() { return $this->emailAddress; } public function setEmailAddress($mail) { $this->emailAddress = $mail; } } class AddressDisplay { private $addressType; private $addressText; public function getAddressType() { return $this->addressType; } public function setAddressType($type) { $this->addressType = $type; } public function getAddressText() { return $this->addressText; } public function setAddressText($mail) { $this->addressText = $mail; } } class EmailAddressDisplayAdapter extends AddressDisplay { public function __construct($mail) { $this->setAddressType('Email'); $this->setAddressText($mail->getEmailAddress()); } } /* ############################################################################################### ############################index.php######################################################## ############################################################################################## */ echo "<ol>"; echo "<li><p>\$email = new EmailAddress()</p></li>"; $email = new EmailAddress(); echo "<li><p>\$email->setEmailAddress('trueline.chirag@gmail.com')</p></li>"; $email->setEmailAddress('trueline.chirag@gmail.com'); echo "<li><p>\$address = new EmailAddressDisplayAdapter(\$email)</p></li>"; $address = new EmailAddressDisplayAdapter($email); echo "<li><p>printing \$address->getAddressType()::</p></li>"; echo "<ul>"; echo "<li><p>".$address->getAddressType()."</p></li>"; echo "</ul>"; echo "<li><p>printing \$address->getAddressText()::</p></li>"; echo "<ul>"; echo "<li><p>".$address->getAddressText()."</p></li>"; echo "</ul>"; echo "</ol>";
Output for 7.3.0 - 7.3.30, 7.4.0 - 7.4.23, 8.0.0 - 8.0.10, 8.1rc1 - rc2
<ol><li><p>$email = new EmailAddress()</p></li><li><p>$email->setEmailAddress('trueline.chirag@gmail.com')</p></li><li><p>$address = new EmailAddressDisplayAdapter($email)</p></li><li><p>printing $address->getAddressType()::</p></li><ul><li><p>Email</p></li></ul><li><p>printing $address->getAddressText()::</p></li><ul><li><p>trueline.chirag@gmail.com</p></li></ul></ol>

preferences:
379.87 ms | 460 KiB | 5 Q