Skip to content

Instantly share code, notes, and snippets.

@Intrepidd
Created July 18, 2011 22:24
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 Intrepidd/1090844 to your computer and use it in GitHub Desktop.
Save Intrepidd/1090844 to your computer and use it in GitHub Desktop.
<?php
class ParentClass {
protected $a = 1;
public function doSomething() {
echo "I'm the parent";
$this->a = 2;
}
}
class childClass {
public function doSomething() {
ParentClass::doSomething();
echo "I'm the child";
echo $this->a;
}
}
$c = new childClass();
$c->doSomething();
@Intrepidd
Copy link
Author

Surprising output!

Try to remove line 13.

@md2perpe
Copy link

What's so surprising about the result?

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