[KLUG Members] PHP & HTML

Richard Harding members@kalamazoolinux.org
Thu, 19 Feb 2004 21:40:18 -0500


*snip*

> <?php
> //in php we do it like this:
> echo "<p align=\"center\">hello world!</p>";
> ?>
>
> <!-- while in HTML we do it like this: -->
> <p align="center">hello world!</p>
>
> Note how the quotes are escaped in PHP.
>
*snip*

I work around this by using a single quote to encase the html. It does 
two things for me. First, PHP looks in every double quote string for 
variables that it needs to replace. This takes time to read every 
string. PHP does not perform this same find/replace on single quoted 
strings. It reduces some overhead. Secondly, it solves the problem of 
having to escape the quotes.

So a line like:
echo( "This is your name: $name" );

becomes
echo( 'This is your name:' . $name );

I find it a bit cleaner and it has the speed benefit.

Rick