Skip to content

Instantly share code, notes, and snippets.

@andrusha
Created June 30, 2011 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrusha/1055648 to your computer and use it in GitHub Desktop.
Save andrusha/1055648 to your computer and use it in GitHub Desktop.
Inheritance example for habrahabr
<?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);
@andrusha
Copy link
Author

Output:
ABB

Because php allows you to pass to functions any number of arguments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment