|
Posted by Rik on 02/01/07 01:35
Uleric <Uleric@gmail.com> wrote:
> Having trouble wrapping this up into a viable statement
>
> I want to check on a users status before allowing a script to be run.
> $myzone can only be 1 variable, but it can be here, there or where.
>
> if ($myzone !=3D=3D ("here") or ("there") or ("where")) { die: }
>
> This does not work however, it will kill the script regardless if one
> of the statments is actually true.
>
> However, this WILL work if only one operator is checked:
>
> if ($myzone !=3D=3D "here") { die: }
>
> If $myzone is "here" the script is allowed to run. If it's anything
> else, it dies, as it is supposed to. However, I want to check if
> $myzone is several options. That is my delima.
Unfortunately, this is not how conditionals work.
You first statement breaks down like:
$myzone !=3D=3D ("here") -> can be true or false
or
("there") -> a string, which cast to a boolean will always be true, no =
further evaluation will be done, conditions are met, code die()s .
You could use a lengthy version:
if (
$myzone !=3D=3D "here" ||
$myzone =3D=3D "there" ||
$myzone =3D=3D "where"){ die: }
Then again, I don't understand you logic. The script is only allowed to =
=
run when it's 'here', so why exactly fo you want to check the rest? If =
$myzone =3D=3D 'here', it cannot be anything else, unless your trying =
something more complex then the example offcourse, in which case I'd be =
=
interested in what exactly.
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|