Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
It is possible to call functions from a static context
class SemiStaticClass {
public function echoWhoIAm() {
echo 'I\'m ' . __FUNCTION__ . ' in class ' . __CLASS__;
// If this doesn't exists, then this function is statically called
if (! isset($this)) {
echo '... and I\'m statically called! Nice!';
echo "\n";
$a = new SemiStaticClass();
// Will output:
// I'm echoWhoIAm in class SemiStaticClass
// I'm echoWhoIAm in class SemiStaticClass... and I'm statically called! Nice!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.