Benim beceri testindeki bazı insanlara göstermek için Sınıfları yazmaya çalışıyorum. Sorulardan biri aşağıdaki gibidir:
Show how a child would call a parent's method. Show how overloading works. Indicate the syntax for class variables.
Yaptığım soru var en düşünüyorum ama emin değilim ne Indicate the syntax for class variables mean ... Birisi bana açıklayabilir misiniz? Thanks a lot!
Class Phone{
function __construct(){
echo "This is the constructor";
}
protected function feature(){
echo "Communication <br>";
}
}
Class CellPhone extends CordlessPhone {
private $brand;
function __construct(){
echo "<p style='color:red;'>Cell phone feature:</p>";
}
function __set($b, $value){
if($value=="Apple"){
$this->brand=$value." is awesome!";
}elseif($value=="LG"){
$this->brand=$value." is nice";
}else{
$this->brand="We only accept Apple and LG";
}
}
function __get($brand){
return "The brand: ".$this->brand."------";
}
public function feature(){
parent::feature();
echo "Play music<br>";
echo "Surf internet<br>";
}
}
Class CordlessPhone extends Phone {
function __construt(){
echo "<p style='color:red;'>Cordless phone feature:</p>";
}
public function feature(){
parent::feature();
echo "Cordless<br>";
echo "Use Battery<br>";
}
}
$phone=new CellPhone();
$phone->feature();
$phone->brand="LG";
echo $phone->brand;