Jump to content

Set static variables from outside a class...


ridiculous

Recommended Posts

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);

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) {

            ...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.