[thelist] help me understand global variable in PHP

Tom Dell'Aringa pixelmech at yahoo.com
Thu Jan 2 12:59:01 CST 2003

--- sasha <spam at bittersweet2.com> wrote:
> Variables within functions don't effect variables within the global
> scope
> (which is what you seem to want), unless you tell them to.
> function yourfunction() {
> 	do stuff..
> 	return $desired_variable;
> 	-or -
> 	return array($desired_variable1, $desired_variable2);
> }
> $product = yourfunction();
> - or -
> $prod_array = yourfunction();
> $desired_variable1 = $prod_array[0];
> $desired_variable2 = $prod_array[1];
> Clear as mud?

Makes sense I think, but I can't call these functions to a variable
that I need, they are being called by event handlers (the php xml
parsing stuff). How can I get my $prodname variable available to me
with the right value outside that function without doing what you
stated above...or can I? (I'm screwed if I can't..).

For reference, my code again is at:



var me = tom.pixelmech.webDeveloper();

[Making A Commercial Case for Adopting Web Standards]

Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.

More information about the thelist mailing list