|
Posted by Shelly on 07/24/05 14:34
<opt_inf_env@yahoo.com> wrote in message
news:1122204562.018664.45780@g49g2000cwa.googlegroups.com...
> Hello,
>
> In some examples of a PHP implementation I saw the following:
> if ( isset(x) and x==12)
> I do not understand what for before to check whether some variable has
> some value one need to check whether this variable is set. If the
> second condition is true than the first one is also true, isn't?
>
The order of checking here is the same as in C, C++, Java, etc. It checks
the first condition. If that fails, it does NOT check the second condition.
If you were to check the second condtion only, then it might cause an error
condition that produces undesirable results. In the case you cite, that
probably won't happen. It is generally used best when you might have a
pointer off into never-never land. So, it is good programming practice to
alway be CERTAIN that your variable being tested actually exists before
testing its value.
Shelly
Navigation:
[Reply to this message]
|