Created
September 13, 2012 12:10
-
-
Save Sannis/3713923 to your computer and use it in GitHub Desktop.
private static vars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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