Danny Brow wrote:
Below is a snip of a program I am writing, I am a little new to php.
Any how, I can't for the life me figure out why one of my functions
cannot grab the item_pics1 variable. I have tried passing the variable
to the function, tried using $GLOBALS['item_pic1']. So I guess my
question is, does PHP in some cases need to have a variable in a if
statement sent back to the global scope? everything works but the
str_replace item_pics1. Hope this is enough code.
<snip>

If you want to use a variable from outside the function, you either have to pass it to the function; if you want to change it, you have to pass it by reference, or make it global inside the function....

function foo ( $bar ) {
        /--code--/
}

function foo ( &$bar ) {
        /--code--/
}

function foo() {
        global $var;
        /--more code--/
}

I may be mistaken, but I think the $GLOBALS array was introduced in 4.3.0.

http://us4.php.net/manual/en/language.variables.scope.php

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to