FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!


<? }?>





gerimter
<? }?> and <? } }?> What is the purpose?
Peterssidan
<?php and <? is the starting tag of php. ?> is the end tag for php. Everything between will be treated as php. Things outside will be treated as plain text. The brackets is probably part of an if statement or a loop or something. It can be used to avoid having print statements in the php code.
Code:
<?php if (x > 5) { ?><b>This is html and will only be printed if x > 5</b><?php } ?>


This would be the same as
Code:
<?php if (x > 5) { print("<b>This is html and will only be printed if x > 5</b>"); } ?>
Fire Boar
It does look rather messy though. I personally prefer to use the alternative "if" syntax for PHP tags within HTML.

Code:
<?php if (x > 5): ?>
  <b>This is html and will only be printed if x &gt; 5</b>
<?php endif ?>
kacsababa
If its something like a view or template file, then I like to use the short tags with the alternate conditional/loop blocks and the shorthand echo starting tag too.
Something like:
Code:
<table>
<? foreach ( $data as $key => $value ): ?>
  <tr>
    <td><?=$key?></td>
    <td><?=$value?></td>
  </tr>
<? endforeach; ?>
</table>
Using the alternate block syntax is mostly better in real life situations when there is more going on in the block then this. Smile
gerimter
Thank you very much.
Related topics
Flash MX
Basic HTML Introduction
Comments
How To : Improve Your PHP Programming
Rudish Jokes
SQL Basics
Q: Why are women so bad at mathematics?
The Death of lol
Dual core or 64 bit?
Forum Problem
This forums having problems?
Forum problem?
How do you show HTML/PHP code on your website?
fundamentos para diseñar un logo para la web
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.