Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi guys. Is it really necessary to set the $name,$email,$gender to NULL? If they are empty, aren't they null then? Thanks!


if (!empty($_REQUEST['name'])) {
$name = $_REQUEST['name'];
else {
$name = NULL;
echo '<p class="error">You forgot to enter your name!</p>';

Link to comment
Share on other sites

Thanks Sir, finding your book really helpful! I'm still a bit confused of the following. If nothing is typed into a particular input field in the form,doesn't that mean that the corresponding variable is unset and therefore Null?

Link to comment
Share on other sites

Hmm thanks Larry and HartleySan (yes, it helps). For the following piece of code, is setting the gender to NULL necessary or is it just a good programming practice? (since if gender is not set, then it automatically means its NULL) Thanks!


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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...