Jump to content

Archived

This topic is now archived and is closed to further replies.

blueboron

\ For Quotation marks

Recommended Posts

Hi,

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

BB

Share this post


Link to post
Share on other sites
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'>";


see
http://www.php.net/manual/en/language.types.string.php

Share this post


Link to post
Share on other sites
You can also note the heredoc syntax also found under Barand's link, example:
[code]
<?php

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" />
</form>

_HTML;

?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.