Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class fruit{
- public $name;
- public $color;
- function set_name($n){
- $this->name = $n;
- echo $this->name;
- }
- protected function set_color($c){
- $this->color = $c;
- echo $this->color;
- }
- }
- class fruit2 extends fruit{
- public function get_color(){
- echo $this->set_color();
- }
- }
- $obj = new fruit();
- echo $obj->set_name("Banana")."<br>";
- $obj2 = new fruit2();
- $obj2->set_name("Yellow");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement