oop - Creating object in PHP of predefined class type -
in program try explore oops concept in php, here things different java. in sample program have created abstract class bird, class parrot extends bird class , interface flyable. after included above class , interface in php file. let have @ code
<?php include 'bird.php'; include 'parrot.php'; include 'flyable.php'; //creating object $bird1=new parrot(); echo $bird1->display(); echo("<br/>"); bird $bird2=new parrot(); //shows error ?>
the thing want ask when try define type of object class bird $bird1= new parrot(); @ line error thing works in java. please let me know how can accomplish thing in php.
you should show error, it's bound due fact you're using java style type hinting on line:
bird $bird2=new parrot();
just remove initial bird
, that's not valid syntax in php.
the place type hints used in php in method parameters. see php docs more information.
Comments
Post a Comment