Hi @all!
I have a question! When I use the isset() function in a PHP script, for example like that:
<?
if(!isset($var)){
echo "Hello World!";
}
else{
echo "ERROR!";
}
?>
and later I look in my error.log file and have got an error:
[Sat Jan 4 16:27:03 2003] [error] PHP Notice: Undefined variable: var in /usr/home/fsascha/htdocs/script.php on line 2
I know the variable was not declared previously! Is this error normal?
Thanks for helping!
Php error on isset() function?
Moderator: General Moderators
- Sascha Speidel
- Forum Newbie
- Posts: 1
- Joined: Sat Jan 04, 2003 10:15 am
- Location: Germany
- Contact:
Yes, it's normal, it's not really an error, it is more of a warning. It is just there to let you know that the variable was previously undeclared. It shouldn't actually cause any trouble for you but if you want to stop those lines from appearing in your logs simply put:
In the code before it's used...of course if you're getting the variable from another source such as the previous page this won't work, then you would have to retrieve it from the $_POST, $_GET, etc...depending on where it is stored. and use that value instead of '' to initialize it...
Code: Select all
$var = '';-
laserlight
- Forum Commoner
- Posts: 28
- Joined: Wed Jan 01, 2003 6:41 am
hmm, why should it be normal for isset()?
http://www.php.net/manual/en/function.isset.php
the user notes seem to indicate that there was no error notice, at least in 2000
http://www.php.net/manual/en/function.isset.php
the user notes seem to indicate that there was no error notice, at least in 2000