Skip to content

Instantly share code, notes, and snippets.

@troelskn
Created March 10, 2010 12:12
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 troelskn/327807 to your computer and use it in GitHub Desktop.
Save troelskn/327807 to your computer and use it in GitHub Desktop.
<?php
class Foo {
protected static $blah;
static function stuff() {
static $cuux = null;
if ($cuux === null) {
echo "It's null.\n";
$cuux = 42;
} else {
echo "It's not null anymore.\n";
}
}
static function stiff() {
if (self::$blah === null) {
echo "It's null.\n";
self::$blah = 42;
} else {
echo "It's not null anymore.\n";
}
}
}
class Bar extends Foo {
}
Foo::stuff(); // It's null.
Foo::stuff(); // It's not null anymore.
Bar::stuff(); // It's null.
Bar::stuff(); // It's not null anymore.
echo "---\n";
Foo::stiff(); // It's null.
Foo::stiff(); // It's not null anymore.
Bar::stiff(); // It's not null anymore.
Bar::stiff(); // It's not null anymore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment