TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   quick question (http://www.talkphp.com/absolute-beginners/4719-quick-question.html)

slobrob 07-11-2009 08:56 PM

quick question
 
hi peoples,

i've just started to learn php and decided to buy PHP a beginners guide by vikram vaswani. only up to the section about if statements switch cases etc which i understand so far. However, in the exmaple given it has put in some code which i dont understand because it has never mentioned it before. can someone please explain it to me?

Thanks,
rob

PHP Code:

<?php 
//if form not yet submitted
//display form
If (!isset($_POST['submit'])) {
?>


Enfernikus 07-11-2009 09:12 PM

$_POST is what is known as a superglobal and contains what is known as post data which is ordinarily sent via form submition.

isset is a function used to check if a variable has been set or not

In this case we're checking if a value has not been set for the $_POST['submit'] and if it's not preform the actions lying betwixt the brackets.

slobrob 07-11-2009 09:17 PM

i know what $_POST means,it was the isset i didnt understand, i should have mentioned that sorry.

so just to clarify in this example i am reading, it contains a web form, so the isset checks to see if the submit button has a value, if it hasnt it will display the web form, if it has then it will process the form?

Normo 07-11-2009 09:56 PM

Actually in this instance the if statement is checking to see if the variable is not set. So if the form has not been submitted then the form will be displayed. Similar to what you said but slightly different. :)

PHP Code:

if (isset($variable)) //if the variable is set
if (!isset($variable)) //if the variable isn't set 

Hope that helps :)

Edit: Yeah, sorry what you said, mis-read it.

Hightower 07-12-2009 06:38 AM

If I'm stuck with a function I Google something along the lines of "PHP Manual isset". Brings up the manual page for that function - got some very good examples for most the functions and has helped me out a great deal.

Good Luck :-)

codefreek 07-12-2009 07:12 AM

google links php to php manual so if you do php + <function name>.
it is the same as PHP Manual, just a tip :)

also if you google, php search toolbar for firefox,
there is many search toolbars for php :)
so you have php manual right in your browser....

-Cf

adamdecaf 07-12-2009 05:10 PM

Quote:

Originally Posted by codefreek (Post 26907)
google links php to php manual so if you do php + <function name>.
it is the same as PHP Manual, just a tip :)

also if you google, php search toolbar for firefox,
there is many search toolbars for php :)
so you have php manual right in your browser....

-Cf

No love for Google Chrome? (type php.net, press tab, enter your query)


All times are GMT. The time now is 12:29 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0