Skip to content

Instantly share code, notes, and snippets.

@ceeram
Forked from lorenzo/trait.php
Created November 17, 2012 17:53
Show Gist options
  • Save ceeram/4098195 to your computer and use it in GitHub Desktop.
Save ceeram/4098195 to your computer and use it in GitHub Desktop.
trait foo { function bob() { echo 'from trait'; }}
class bar { use foo { bob as likeBob }; function bob() { $this->likeBob();}}
class baz extends bar { function bob() { parent::bob(); echo ' from child'; }}
$a = new baz;
$a->bob();
//result: from trait from child
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment