3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Products{ // Properties protected $_title; protected $_category; // Methods public function __construct($title, $category){ $this->_title = $title; $this->_category = $category; } public function getCategory(){ return $this->_category; } public function getTitle(){ return $this->_title; } } class Order extends Products{ // Properties protected $_price; protected $_deliver; // Methods public function __construct($title, $category, $price){ parent::__construct($title, $category); $this->_price = $price; $this->freeDomesticShipment(); // method called (in this case a protected method, so only reachable from whitin the class. Could also have been private.) } public function getPrice(){ return $this->_price; } public function getDeliver(){ return $this->_deliver; } protected function freeDomesticShipment(){ $this->_deliver = $this->_price > 30 ? 'Yes' : 'No' ; } } $order = new Order('CD Brahms', 'Media', '45'); echo 'Product: '.$order->getTitle(); echo 'Categorie: '.$order->getCategory(); echo 'Prijs: '.$order->getPrice(); echo 'Gratis bezorging: '.$order->getDeliver();
Output for git.master, git.master_jit, rfc.property-hooks
Product: CD BrahmsCategorie: MediaPrijs: 45Gratis bezorging: Yes

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:
42.5 ms | 401 KiB | 8 Q