<?php
* Interfaces may not include member variables
* Interface function cannot contain body
<?php
interface fruit {
function eatme();
function buyme();
function goodat();
}
class mango implements fruit {
function eatme(){ echo "Eat me! I\"m so sweet" ."\n <br>";}
function buyme(){ echo "you can buy me direcly from farm"."\n <br>";}
function goodat(){ echo "I\"m good at proteins" ."\n <br>" ;}
}
//$apple = new fruit; #PHP Fatal error: Cannot instantiate interface fruit
//$apple->eatme();
$malgova = new mango ;
$malgova->eatme(); #Eat me! I"m so sweet
$malgova->buyme(); #you can buy me direcly from farm
$malgova->goodat(); #I"m good at proteins
?>
Return to Kesavan Muthuvel's home page. Please send comments on these web pages to hi@kesavan.info (or) Feedback here CopyLeft (Ͻ) 2008 - 2023 Kesavan Muthuvel More on CopyLeft |