<?php
class Product
{
/* Static Methos and Properties example */
public static $manufacturer = "Bart Taylor";
public $name = 'default_name';
public $price = 0;
public $desc = 'default description';
function __construct($name, $price, $desc){
$this->name = $name;
$this->price = $price;
$this->desc = $desc;
}
public function getInfo(){
return "Product Name: ". $this->name;
}
public function getMaker(){
return self::$manufacturer;
}
}
/* Part on Object Inheritance */
//SUB-CLASS
class Soda extends Product
{
public $flavor;
function __construct($name, $price, $desc, $flavor){
parent::__construct($name, $price, $desc);
$this->favor = $flavor;
}
public function getInfo(){
return "Product Name: ". $this->name . "Flavor: ". $this->flavor;
}
}
$shirt = new Product("Space Juice T-Shirt", 20, "Awesome Grey T-Shirt");
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Ga4JW on line 7
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Ga4JW on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/Ga4JW on line 7
Process exited with code 255.