ridiculous Posted August 10, 2008 Share Posted August 10, 2008 Does anyone know how to set static variables from outside a class? i.e. class Example { //I want to set a static variable here from outside the class. function test(){ //Then I want to call the variable here. I know that I could include it as a argumennt //in the function call, //but I want to make things easier by using the same static variables for multiple //function calls } } $obj = new Example($staticVariable); Link to comment https://forums.phpfreaks.com/topic/119011-set-static-variables-from-outside-a-class/ Share on other sites More sharing options...
ignace Posted August 10, 2008 Share Posted August 10, 2008 if you would read a manual you would know! That same reason applies why you don't get any replies! Here, you get this one for free: class Example { protected static $_var; public static function test() { if (null === self::$_var) { ... Link to comment https://forums.phpfreaks.com/topic/119011-set-static-variables-from-outside-a-class/#findComment-612864 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.