[thelist] PHP inside or outside?
Tony Crockford
tonyc at boldfish.co.uk
Sat Apr 24 13:06:59 CDT 2004
At 14:28 on Saturday, 24 Apr 2004, Richard Davey wrote:
> Hello Tony,
>
> Saturday, April 24, 2004, 1:00:23 PM, you wrote:
>
> TC> I also find it easier to read echo'd php variables within html than
> to
> TC> read echo'd html within PHP
> TC> (all those escaped characters - makes it look really untidy.)
>
> I'd have to disagree on this one for the simple fact that if you're
> writing XHTML compliant code, you need to quote everything - and if
> you're injecting variables into your echo statement, you then need to
> escape all of the quotes which can lead to lots of parser errors IMHO.
>
> (or you echo with single quotes and then cannot use variables inline,
> so have to break out, concat them, etc.. quite messy too).
>
> The more times you swap in and out of HTML/PHP, the more work the PHP
> parser has to do - but to be honest I bet the speed difference in this
> regard is absolutely tiny, so it's best to treat this one as a "do
> whatever suits you" situation.
what I meant was that this:
echo "<a class=\"lightright\"
href=\"description_view.php?idc_ref=$parent_ref\" title=\"go back\" >Back
to Description</a>";
is harder (for me) to read than this:
<a class="lightright" href="description_view.php?idc_ref=<? echo
$parent_ref;?>" title="go back">back to description</a>
especially when the page is mostly xhtml with a few bits of PHP logic.
mostly because each quoted attribute needs escaping and I have a habit of
forgetting and then the PHP fails.
as you say - "whatever suits you"
;o)
More information about the thelist
mailing list