PDA

View Full Version : Getting around backslashing " in PHP



FlashNewby
December 31st, 2004, 07:05 PM
Hi,
As a developer I do a fair amount of JSP and Java development and want to learn PHP. The problem I have with it is that you have to backslash all the quotes in the html. This reminds me when I started out doing servlets and had to backslash quotes(this was before I found jsp) this is very annoying. Does anyone know a way around this.

Thanks

andr.in
December 31st, 2004, 08:06 PM
use single quotes for one and double for the other...like

echo '<foo class="foo"></foo>';

RushScripting
December 31st, 2004, 10:18 PM
Yes that is the only way really. You can switch between one or the other, i prefer the opposit for some reason but that's just me :P

FlashNewby
January 1st, 2005, 12:43 AM
use single quotes for one and double for the other...like

echo '<foo class="foo"></foo>';
Syko does this work only with the echo method or will this work also with using print?

andr.in
January 1st, 2005, 07:51 AM
that works with everything

λ
January 1st, 2005, 08:35 AM
Alternatively, you could use Heredoc syntax (http://dk2.php.net/manual/en/language.types.string.php#language.types.string.sy ntax.heredoc) :)

FlashNewby
January 1st, 2005, 12:11 PM
Thanks. This HereTo looks very interesting. Will get back to you.