Skip to content

Instantly share code, notes, and snippets.

@DrewAPicture
Created May 19, 2016 18:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrewAPicture/bec0e76d5b4c618ee3c4184eea8db6af to your computer and use it in GitHub Desktop.
Save DrewAPicture/bec0e76d5b4c618ee3c4184eea8db6af to your computer and use it in GitHub Desktop.
<?php
class Beer {
const NAME = 'Beer!';
public static function printed(){
echo 'static Beer:NAME = '. static::NAME . '<br />';
}
}
class Ale extends Beer {
const NAME = 'Ale!';
public static function printed(){
forward_static_call(array('parent','printed'));
call_user_func(array('parent','printed'));
forward_static_call(array('Beer','printed'));
call_user_func(array('Beer','printed'));
}
}
Ale::printed();
echo '</pre>';
// Outputs:
// static Beer:NAME = Ale!
// static Beer:NAME = Ale!
// static Beer:NAME = Ale!
// static Beer:NAME = Beer!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment