This is a discussion on "PHP syntax query" within the PHP Forum section. This forum, and the thread "PHP syntax query are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
PHP syntax query
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Quote:
1. Why does the initial IF statement start with IF, to be followed by an opening brace, and then that piece of script closed? It's like saying, If so-and-so... forget it. 2. Then the third piece of script starts with a closing brace. 3. Therefore, why does an opening and closing brace overlap the end of one script and beginning of another? Any helpful explanation appreciated. Cheers |
|
|
|
|||
|
Re: PHP syntax query
I'm not sure you can close a PHP block in the middle of am if else statment. I would have to look into that and try it. I would echo the entire form and escape the quotation marks where needed.
The second if else statement is a nested selection structure. Meaning that if submit is never set, the script never gets the else part of the selection structure, therefore never getting to the nested if else statement. I don't see where anything starts with a closing brace? If you mean the closing brace under "Come on in, we have alcohol and music awaiting you". That is the closing brace for the if age >= 21 part of the script. Then goes to the else part where the user is not 21 of over. Hope this helps, Scott |
|
|||
|
Re: PHP syntax query
Ending with an opening brace, lines 3 and 4:
{ ?> Lines 11 and 12, starting with a closing brace: <?php> } It's in an online tutorial, and the script runs OK. I've seen it elsewhere as well. In fact it's here under Part 4: http://www.goodphptutorials.com/track/229 Last edited by matelot; Jul 7th, 2007 at 15:31. |
|
|||
|
Re: PHP syntax query
Ahhhh Ok I see what you mean! That is because the PHP code is interrupted by HTML. So the PHP block has to be closed and reopened. That was why I had mentioned echoing the entire form and escaping the quotation marks. That seems to me to be more of a logical approach (but that's just my opinion).
If the script works, I guess you can interrupt a a selection structure and reopen it. Not sure if you know what I mean by escaping, but here a quick example though it is not tested.
Hope this helps, Scott |
|
|||
|
Re: PHP syntax query
Quote:
Many thanks so far. |
![]() |
| Tags |
| curly braces, php, syntax |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| scene syntax | Rick | Flash & Multimedia Forum | 5 | Sep 27th, 2007 21:25 |
| Help with syntax | tox0tes | PHP Forum | 3 | Sep 3rd, 2007 03:00 |
| Valid php syntax | nate2099 | PHP Forum | 2 | Jul 18th, 2007 04:23 |
| MySQL query query | dangergeek | Databases | 3 | Apr 12th, 2007 12:45 |
| error in SQL syntax | Drgreenfingers | Databases | 10 | Jan 30th, 2006 02:00 |