Helping ordinary people create extraordinary websites!

Stopping Quotation Mark Errors in PHP

By Ben Sinclair
2005-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:

<?php

if ($this == "that") {
print "Hello! This is a piece of "text!" Cool huh?";
}
?>
You 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:

<?php

if ($this == "that") {
print "Hello! This is a piece of \"text!\" Cool huh?";
}
?>
"What if I have 100's of QA's already and don't want to put a BS in front?"

That's easy too! You just put an end tag before the text and a start tag after the text:

<?php

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
}
?>
That's how you do it.

Hope that helps!



Tutorial pages:
  • Stopping Quotation Mark Errors in PHP
 1 Votes

You might also want to check these out:

Comments:

NigelN1
I am now learning PHP and I have become great friends with errors in PHP as I see them all the time :-). This tutorial even in its simplicity has helped me understand why I have been getting some of the PHP errors I have been getting. One error down a thousand more to go.
Tuesday, 13th October 2009 at 11:17:49 PM


Leave a Comment on "Stopping Quotation Mark Errors in PHP"
You must be logged in to post a comment.

Link to This Tutorial Page!


GET OUR NEWSLETTERS