Jump to content


\ For Quotation marks

  • Please log in to reply
3 replies to this topic

#1 blueboron

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 29 October 2006 - 10:24 AM


I am a complete newbie with php.

I want to design a table in Microsoft Frontpage and place it on my source page - however php requires a \ before quotation marks - Unfortunately the table code has about a zillion quotation marks :'( - is there anyway of solving this problem to save me going mad and updating each \

I look forward to any replies

Thank you


#2 Barand

  • Moderators
  • Sen . ( ile || sei )
  • 18,025 posts

Posted 29 October 2006 - 10:42 AM

The \ is only required in some circumstances

If you have

$str = "<img src="a.gif">";

then this would give an error since the " after the = would terminate the string value. So you would need

$str = "<img src=\"a.gif\">";

to include the " in the value.

If you enclosed the whole string in single quotes, you wouldn't need to escape the " with \. So this is OK

$str = '<img src="a.gif">';

and so is

$str = "<img src='a.gif'>";

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received


|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 alpine

  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 29 October 2006 - 10:53 AM

You can also note the heredoc syntax also found under Barand's link, example:

echo <<<_HTML

Here you can mix both $variables and "quotes" within php
and newlines will be treated as newlines in the source code.

<form method="post" action="page.php">
<input type="text" name="field" value="$value" />
<input type="button" value="whatever" />



#4 blueboron

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 29 October 2006 - 01:27 PM

Thanks very much - I have now put php & html on the same page and it all works well :)

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users