Stopping Quotation Mark Errors in PHP
By Ben Sinclair2005-04-20
Stopping Quotation Mark Errors in PHP
-------------------------------------------------------------------
Note: This is a tutorial I wrote when I was learning PHP. It
might come in handy for you too :D
-------------------------------------------------------------------
Do you get errors when you write something like this:
<?phpYou will get errors until you remove the Quotation Marks(QA). How can you have a QA without getting errors? Simply but putting a Backslash(BS) in front of it:
if ($this == "that") {
print "Hello! This is a piece of "text!" Cool huh?";
}
?>
<?php"What if I have 100's of QA's already and don't want to put a BS in front?"
if ($this == "that") {
print "Hello! This is a piece of \"text!\" Cool huh?";
}
?>
That's easy too! You just put an end tag before the text and a start tag after the text:
<?phpThat's how you do it.
if ($this == "that") {
?>
Hello! This is a piece of "text!" Cool huh? I can have as many " as I like! See: " " " " " etc. etc. :D
<?php
}
?>
Hope that helps!
Tutorial Pages:
» Stopping Quotation Mark Errors in PHP
