#15 Globals variables in subs.inc

open
nobody
None
5
2005-11-17
2005-11-17
KemenAran
No

I had a problem while trying to implement Program E in
a custom OO Framework of mine. I just included the
'respond.php' file in a method of a class, and
everythings worked properly but one thing : the
subs.inc arrays.

It seems Program E is not supposed to be runned inside
an object, because the variables declarated at the root
of the script (like the subs.inc arrays) are intended
to be globals. It is obviously no more the case when
calling Program E from an object.

This was generating some strange and erratic behaviors
of the robot, and I spend two hours tracking down the
problem ; then one minute to fix it : I just changed
the definition of the arrays inside subs.inc, from
'$*search=array(...);' to
'$GLOBALS['*search']=array(...);'. This can be
automatically generated by changing the first line of
the function 'makesrphp()' in the file
'bootloaderfuncs.php', just replace it by
'$myphp="\$GLOBALS['" . $sname . "search']=array(\n";'.
A couple of similar lines in the same function need to
be changed the same way.

I don't think this breaks or slows down anythings, but
it'll be very usefull to avoid the problem reproducing
again.

Thanks for you cool program :)

Discussion