Created
June 30, 2011 04:40
-
-
Save andrusha/1055648 to your computer and use it in GitHub Desktop.
Inheritance example for habrahabr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class A { | |
public function setSize($x, $y) { | |
print('A'); | |
} | |
} | |
class B extends A { | |
public function setSize($x) { | |
print('B'); | |
} | |
} | |
$a = new A(); | |
$a->setSize(1, 2); | |
$b = new B(); | |
$b->setSize(1); | |
$b->setSize(1, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output:
ABB
Because php allows you to pass to functions any number of arguments