Jump to content

\ For Quotation marks


blueboron

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
Link to comment
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
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.