Skip to content

Instantly share code, notes, and snippets.

@jasonrhodes
Created June 5, 2012 20:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jasonrhodes/2877783 to your computer and use it in GitHub Desktop.
Save jasonrhodes/2877783 to your computer and use it in GitHub Desktop.
Self vs Static in PHP
<?php
class A
{
public static $var = "I'm set in A!<br>";
public static function getStatic() {
echo static::$var;
}
public static function getSelf() {
echo self::$var;
}
}
class B extends A
{
public static $var = "I'm set in B!<br>";
}
B::getSelf(); // I'm set in A!
B::getStatic(); // I'm set in B!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment