Jump to content

Help with boolean variables, and going in and out of <?php ?> tags


Go to solution Solved by Jessica,

Recommended Posts

So I'm just learning PHP and MySQL for the first time, and I've been doing really well. I have a lot of experience with HTML and C++ so a lot of concepts are very familiar. I'm currently using if { to determine whether or not an HTML form field has any data in it or not. If either of two fields are empty, it echoes a warning to the user and re-prints the form on the resulting page.

 

Here's a link to a pastebin of what I currently have.

 

Note that I have tried $form_output both as 'true' and 'false' & also just as plain true and false (no quotes). Both seem to fail when I reach the if statements. Even if the $subject or $body variables are false, it still starts sending the emails in the if ($output_form = false) section.

 

So my question is partially - does PHP recognize true and false without quotes as boolean variables? Or does it just think they are plain text? I figured that because they have no quotes, if it didn't recognize them as special terms it would crash the script at that point. I need to learn how to use a PHP debugger on Linux, so if someone could help me with that too, that'd be great. I probably wouldn't even have to ask this question because the debugger would have shown me what the script is actually doing.

 

My other question is, the book I'm learning from shows the script going in and out of the <php? tags, back to HTML, then back into <php? to close the script (at the bottom of the above link). Is that accepted syntax or is that incorrect?

 

Thanks a lot in advance for your help!! Much appreciated.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.