3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Account { private $account_number; private $balance; private $branch; private $account_owner; private $atm_issued; function __construct($account_number,$balance,$branch,$account_owner,$atm_issued) { if($account_owner instanceof AccountHolder) { $this->account_number = $account_number; $this->balance = $balance; $this->branch = $branch; $this->account_owner = $account_owner; $this->account_owner->setAccount($this); $this->atm_issued = $atm_issued; } else { echo "Not a valid accountholder"; die(); } } } class SavingsAccount extends Account { private static $type = "SavingsAccount"; public static function getTypeOfAccount() { return self::$type; } } class CurrentAccount extends Account { private static $type = "CurrentAccount"; public static function getTypeOfAccount() { return self::$type; } } class AccountHolder { private $fullname; private $age; private $mobile; private $account; function __construct($name,$age,$mobile) { $this->fullname = $name; $this->age = $age; $this->mobile = $mobile; } public function setAccount($account) { $this->account = $account; } } $person_1 = new AccountHolder("James",21,9495786); $account_1 = new CurrentAccount(123456,7896.00,"Kochi",$person_1,false); $person_2 = new AccountHolder("John",29,974767345); $account_2 = new SavingsAccount(978563,18765.00,"Pala",$person_2,true); print_r($account_1); print_r($account_2); ?>
Output for git.master, git.master_jit, rfc.property-hooks
CurrentAccount Object ( [account_number:Account:private] => 123456 [balance:Account:private] => 7896 [branch:Account:private] => Kochi [account_owner:Account:private] => AccountHolder Object ( [fullname:AccountHolder:private] => James [age:AccountHolder:private] => 21 [mobile:AccountHolder:private] => 9495786 [account:AccountHolder:private] => CurrentAccount Object *RECURSION* ) [atm_issued:Account:private] => ) SavingsAccount Object ( [account_number:Account:private] => 978563 [balance:Account:private] => 18765 [branch:Account:private] => Pala [account_owner:Account:private] => AccountHolder Object ( [fullname:AccountHolder:private] => John [age:AccountHolder:private] => 29 [mobile:AccountHolder:private] => 974767345 [account:AccountHolder:private] => SavingsAccount Object *RECURSION* ) [atm_issued:Account:private] => 1 )

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:
95.21 ms | 403 KiB | 8 Q