On Wednesday 25 April 2001 13:28, ahmad varoqua wrote:
> Hello, I too am a novice and have the same problems with "warning:
> undefined variable" or "undefined index" when I have display errors
> 'on'. The scripts work fine and I have reg_globals 'off' (I've been
> following that thread closely as well!) . How critical are these
> warnings? Is it overenthusiam on php's error tracking? You say to
Well, "undefined variable" for example means, that at
if ($foobar == 0) {...}
$foobar hasn't been set to anything so far - it's value is undefined,
meaning that the if() can do what it wants.
> 'correct the code' and I believe you, but what should I do? I want my
Well, for example when working with URL parameters (which may or may not
be set), use some wrapper function to access them. I use this code:
/*
* Get global variable <name>
* Automatically strips slashes when needed
*/
function pbGetGlobal ($Name)
{
if (isset ($GLOBALS[$Name])) {
if (get_magic_quotes_gpc () &&
is_string ($GLOBALS[$Name]))
return stripslashes ($GLOBALS[$Name]);
else
return $GLOBALS[$Name];
}
else
{
return "";
}
}
$MyVar = pbGetGlobal ("foobar");
if ($MyVar == 0) {...}
--
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)
"Software is like sex: the best is for free" -- Linus Torvalds
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]