Re: Which way is better?
| From: | Justin French | Date: | Fri, 09 May 2003 00:13:05 +0000 |
| Subject: | Re: Which way is better? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146953@lists.php.net to get a copy of this message | ||
The difference is neglegable, and the general consensus of the list (which
I've been on for around 3 years) seems to be "whatever you're more
comfortable with, and whichever makes more sense.
For me, I attempt to stay in PHP whenever possible, but sometimes it makes
more sense to go back to html, like a 20 line table, or something with lots
of quotes which in turn need escaping, which in turn make things unreadable,
eg:
<?
if($foo) {
echo "<a href=\"javascript('foo({$somevar}')\"
target=\"_blank\">Click
\"here\"</a>";
}
?>
is much easier for ME to read as:
<? if($foo) { ?>
<a href="javascript('foo(<?=$somevar?>')"
target="_blank">Click "here"</a>
<? } ?>
Do whatever you think makes your code:
a) faster to write
b) easier to read
c) easier to maintain
... and don't worry about the tiny tiny difference in performance, if any.
Justin French
on 09/05/03 12:00 PM, Ben Cheng (kenshin@mac.com) wrote:
> Is it better to code this way:
>
> <?
> if ($option == 1) {
> echo "Blah blah.";
> }
> ?>
>
> or:
>
> <? if ($option == 1) { ?>
> Blah blah.
> <? } ?>
>
> Is there a performance difference or just a matter of readability?
>
> -Ben
>