Skip to content

Instantly share code, notes, and snippets.

@Sannis
Created September 13, 2012 12:10
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 Sannis/3713923 to your computer and use it in GitHub Desktop.
Save Sannis/3713923 to your computer and use it in GitHub Desktop.
private static vars
<?php
class Example {
private static $a = array(1, 2);
private static $b = null;
public static function init()
{
if (self::$b === null) {
self::$b = self::$a[0];
}
}
public static function yourFunction()
{
self::init();
return self::$b;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment