Hi!
J�Rgen wrote:
> It's me again, i don't mean to be a bugger, but i really like to learn as
> much as possible, that's why i ask (or will ask so many questions).
>
> Consider the following (i shortened this a lot, but it will do the trick)
>
> $op = $_GET['op'];
> switch ( $op )
> {
> case "admin":
> DoLogin();
> break;
>
> default:
> ShowHomepage();
> break;
> }
>
> PHP shoots a Notice Message telling me that there is an undefined index
> Undefined index: act in g:\apache_web\intern\looney\index.php on line 177
You get this error message whenever $_GET doesn't contain anything.
> This accects the code shown above.
>
> Ok, am i correct in assuming that it pops this message because $op is not
> defined as anything yet?
>
> If so,should i always just do this
>
> $_POST['op'] = '';
> $op = $_GET['op'];
> switch ( $op )
> {
> //Code here
> }
>
> Or would it be better and more space efficient to do this
> $op = isset($_GET['op']);
> switch ( $op )
> {
> //Code here
> }
> Cause if i do that the Notice Message dissapears for some reason i yet fail
> to grab.
This doesn't work since the result of isset($_GET['op']) is either true
or false, not a string value. You need to write it like this:
if (isset($_GET['op']) {
$op = $_GET['op'];
switch ($op)
{
//Code here
}
}
> I would really appreciate if somebody could explain to me why the Notice
> dissapears when using isset(), and also what is the best method to use
> rather then the two shown above?
> How do you guys&girls handle this?
>
> Thanks a lot in advance for your time and patience!
>
> Best regards from Vienna,
> J�rgen
>
>
>
Hope this helps!
/lasso ([EMAIL PROTECTED])
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php