<?php
class Productss{
protected $title;
protected $category;
const CHANGES_SAVED = 'Wijzigingen opgeslagen';
public function __construct($title, $category){
$this->title = $title;
$this->category = $category;
}
public function someFunction(){
self::CHANGES_SAVED; // CHANGES_SAVED not changeable in this class, it is changeable in a child class
}
public function getCategory(){
return $this->category;
}
public function getTitle(){
return $this->title;
}
}
class Order extends Productss{
protected $price;
protected $deliver;
const CHANGES_SAVED = 'Wijzigingen nu opgeslagen';
public function __construct($title, $category, $price){
parent::__construct($title, $category);
$this->price = $price;
$this->doWeDeliver();
}
public function getPrice(){
return $this->price;
}
public function getDeliver(){
return $this->deliver;
}
protected function doWeDeliver(){
$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();
echo Productss::CHANGES_SAVED.'<br />'; // 300
echo Order::CHANGES_SAVED.'<br />'; // 500
Wijzigingen opgeslagen<br />Wijzigingen nu opgeslagen<br />
Output for 5.1.0
<br />
<b>Fatal error</b>: fatal flex scanner internal error--end of buffer missed in <b>/in/rFXJD</b> on line <b>54</b><br />
Process exited with code 255.
Output for 4.4.2 - 4.4.9
<br />
<b>Parse error</b>: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/rFXJD</b> on line <b>4</b><br />
Process exited with code 255.
<br />
<b>Parse error</b>: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/rFXJD</b> on line <b>4</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br />
<b>Parse error</b>: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in <b>/in/rFXJD</b> on line <b>4</b><br />
Process exited with code 255.