The syntax is a bit screwed up too (unless you just aren't posting all of the code). This code is missing end statements. When you indent things to follow the ifs, you will see 2 nested if statements with no ends. You can test this out by assigning the $set_var and $never_set variables before the if/else statements.
<?
// Change these values to play around a bit.
$set_var = '0';
$never_set = '0';
print("set_var print value: $set_var<br>");
print("never_set print value: $never_set<br>");
// Although this works, the code could be better written to do these checks. (Actually, there is a flaw: See below)
if ($set_var == $never_set):
print("set_var is equal to never_set!<br>");
if (IsSet($set_var)):
print("set_var is set.<br>");
else:
print("set_var is not set.<br>");
if (IsSet($never_set)):
print("never_set is set.<br>");
else:
print("never_set is not set.");
endif;
endif;
endif;
// Code edited to include the endifs, after getting called out by laserlight ;-) My bad.
?>
The above code should output the following:
set_var print value: 0
never_set print value: 0
set_var is equal to never_set!
set_var is set.
It should never process the $never_set isset portion of the code since it is nested in the else portion of the $set_var isset portion of the code. Since $set_ver is set, it will not process the else portion of the code.
I personally don't use that book, but begin to wonder about the validity of the code in it, if it makes this kind of simple mistake...