Hi i have a strange problem with a WordPress plugin that i am writing, but this isnt about WordPress per se and more to do with PHP so please read on so I can explain. The WordPress plugin is hooked up so that the init() function gets called… this works i can confirm it gets called once.
public static function init()
public static function dosomething()
echo ‘i is = ‘ . self::$i;
When callinf dosomething() for the first time from within WordPress it is ok. I then have another ajax-response.php file which includes the above class and again calls dosomething, which prints the i value = 1.
The problem is the i value when calling via the ajax-response.php script is back to 0?
Its as if it is executing in a totally different memory space and creating a new program, such that static member variables are only shared between same process as opposed to multiple web threads.
Thanks in advance,
- The topic ‘PHP static member not holding value’ is closed to new replies.