Gerard-Meier

Virtual

Apr 21st, 2012
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.35 KB | None | 0 0
  1.  
  2.  
  3. class Bike {
  4.     public function whatAreYou() {
  5.         print "I'm a bike.";
  6.     }
  7. }
  8.  
  9. class Car extends Bike {
  10.     public function whatAreYou() {
  11.         print "I'm a car.";
  12.     }
  13. }
  14.  
  15.  
  16. $car = new Car();
  17.  
  18. // So we cast the car to its super class and assign that to a new variable.
  19. $bike = (Bike) $car;
  20.  
  21. // So what does this output?
  22. print $bike->whatAreYou();
Advertisement
Add Comment
Please, Sign In to add comment