Jump to content
Larry Ullman's Book Forums

Why Is There A Difference In 2.4


Recommended Posts

When doing the if else for the gender at steps 5, 6 and 7 he writes that the code should go

 

if (isset($_REQUEST['gender'])) {$gender = $_REQUEST['gender'];

                if ($gender == 'M') {$greeting = '<p><b>Good Day, Sir!</b></p>';}

                elseif ($gender == 'F') {$greeting = '<p><b>Good Day, Madam!</b></p>';}

                else {$gender = NULL; echo '<p class="error">Gender Should be either "M" or "F"!</p>';}

            else {$gender = NULL;
            echo '<p class="error"> You forgot to select your gender!</p>';}

 

Yet when you look at the example code in 2.4 it is written as:

 

if (isset($_REQUEST['gender'])) {$gender = $_REQUEST['gender'];

                if ($gender == 'M') {echo '<p><b>Good Day, Sir!</b></p>';}

                elseif ($gender == 'F') {echo '<p><b>Good Day, Madam!</b></p>';}

                else {$gender = NULL; echo '<p class="error">Gender Should be either "M" or "F"!</p>';}

            else {$gender = NULL;
            echo '<p class="error"> You forgot to select your gender!</p>';}

 

I seem to have missed why there is the difference in the two examples. Is one right and not the other? Does it matter which way you do it? Am i just totally over looking something? Wondered if i could get any help.

Link to comment
Share on other sites

I am not an expert or anything but i have the ebook on my computer and the two codes above are the two codes given. The one with "$greeting" is how you say to do it in step 6 and the one with "echo": is what the example shows. There is a possibility I am wrong, I am not rulling that out, but I wanted to know what i am missing.

Link to comment
Share on other sites

  • 2 years later...
 Share

×
×
  • Create New...