Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Build a Simple PHP Application Adding a Contact Form Working with Get Variables

Rifqi Fahmi
Rifqi Fahmi
23,164 Points

what the meaning of this sentence in this video??

I still didn't understand what the meaning of this sentence in this video:

if that variable doesn't exist at all, then this conditional would 
generate a notice that might be visible in the browser.

anyone can explain it to me :) ?? thanks :)

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,631 Points

Hey Rifqi,

What Randy is trying to say is that without also checking to see if the variable is set, the conditional could return an error that could possibly show up on the website's page, which you don't want because that would confuse the visitor. Instead, you check to make sure it is set and equal to ...

So, both conditions need to be met before that block will run. Now, if it isn't set, it won't try to return a non-existent variable and won't throw an error. It will just go back to the contact screen.

Does that make sense?

:)

Rifqi Fahmi
Rifqi Fahmi
23,164 Points

is the error happen because the conditional statement run ?? how is the error look like ?? how that conditional statement run when there is no variable which meant exist ?? :)

Jason Anders
Jason Anders
Treehouse Moderator 145,631 Points

If I remember this course correctly, the GET variable is set when the form is successfully submitted, and the variable 'thanks' would then be set.

If for some reason (and there could be many) the contact form fails in what is was programmed to do, then the GET variable would not be set and therefore would not technically exist. This is what isset is checking for. Without that check, if something did go wrong, an error could be thrown to the page.

Rifqi Fahmi
Rifqi Fahmi
23,164 Points

OK thanks jason, now that make sense to me :)