PHP static variable as a result of another function -
i trying define php class static variables. trying following avoid using globals.
class class_name{ private static $var1 = is_plugin_inactive('plugin/plugin.php'); //check if wordpress has plugin active public static function dosomestuff(){ echo $var1; } } //init class class_name::dosomestuff();
this get's me error parse error: syntax error, unexpected '(', expecting ',' or ';' in my_file.php
@ line defining static variable.
any please.
not sure of exact situation, can do:
class class_name { private static $var1 = null; //check if wordpress has plugin active public static function dosomestuff(){ if(is_null(self::$var1)) self::$var1 = is_plugin_inactive('plugin/plugin.php'); echo self::$var1; } }
basically call function wanting to, initialize if not already?
Comments
Post a Comment