Forum Moderators: coopster

Message Too Old, No Replies

Question coding

         

skyhigh007

4:57 pm on Jun 5, 2006 (gmt 0)

10+ Year Member



Here's the code

<?php
if (isset($_POST['Debug']) and $_POST['Debug'] == "on") {
?>
<pre>
<?php
print_r($_POST);
?>
</pre>
<?php
}
?>
<p align="center"><?php echo $_POST['Greeting'];?>
<?php $_POST['Name'];?></p>

question: why you need a PHP tag for "}"?

coopster

5:21 pm on Jun 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



It marks the end of the "if" control structure. Every part of PHP code MUST BE enclosed in PHP opening and closing tags [php.net].

skyhigh007

6:19 pm on Jun 5, 2006 (gmt 0)

10+ Year Member



why cant all the code be put it in one php tag?

coopster

6:24 pm on Jun 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



It can, if you want. You can bounce in and out of PHP mode anytime you like. You can get out to use regular HTML or you can use PHP to print [php.net] the HTML out for you.
<?php 
if (isset($_POST['Debug']) and $_POST['Debug'] == "on") {
print '<pre>';
print_r($_POST);
print '</pre>';
}
?>
<p align="center">
<?php
echo $_POST['Greeting'];
echo $_POST['Name'];
?>
</p>

skyhigh007

6:54 pm on Jun 5, 2006 (gmt 0)

10+ Year Member



During the process of parsing, the parser only looks for the codes that are within the PHP Tag and ignores the codes that are outside of PHP Tag? If i'm wrong can you elaborate more on how Parsing works?

coopster

7:08 pm on Jun 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Yes, that's about it. Did you read the linked page in message number 2? Details are all there.