I have a function that is called once for initiation, and then later as a callback. I need some of the values that were defined in the initial setup to be accessed in the callback.
I am unsure of exactly what happens to the variables in the 'init' section after it closes. Clearly the static is available to the callback section when it is called. However is the object available as well? Or is it unset after the 'init' section returns? If it is lost, is it possible to assign an object to a static variable? Such as $static = $object;
before the return;
line?
function someFunction($type) {
if ($type == 'init') {
static $static;
$object = new stdClass();
$object->property = 'value';
return;
}
elseif ($type == 'callback') {
//Stuff that uses $object->property
return;
}
}