RE: GtkCombo global variables problem
| From: | Rhys Campbell | Date: | Tue, 08 Jun 2004 15:17:11 +0000 |
| Subject: | RE: GtkCombo global variables problem | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-4636@lists.php.net to get a copy of this message | ||
For those interested, regarding my earlier problem with GtkCombo values, if you remember I solved
this problem by returning the variable at the end of the function. but I have discovered that this
will not work (as I expect)
function function1()
{
$var1 = "Blah, blah, blah";
}
function function2()
{
echo $GLOBALS['$var1'];
}
This will not function if a variable in another function is accessed although if it is in the main
section of code it will function correctly. This adaptation will work...
function function1()
{
global $var1; // declare global here
$var1 = "Blah, blah, blah";
}
function function2()
{
echo $GLOBALS['$var1'];
}
Seems we need to declare it as being global upon birth and when we access it. Not too troublesome
now I know but the lack of an error previously did throw me a bit. Could this be considered a bug???
Regards,
Rhys Campbell
DA Systems
e: rhys.campbell@da-systems.co.uk
t: +44(0)1494 512626
f: +44(0)1494 512727
w: www.da-systems.co.uk