/    Sign up×
Community /Pin to ProfileBookmark

A simple echo-ing problem

Hi everyone,

Quick question. Anybody know why the code below would give the output after it?

Thanks

[code=php]
echo “nt</td>nt<td>ntt<ul>nttt<li>Edit</li>nttt<li><a title=”Delete this design” onclick=”delete(this, “yes”) href=”#”>Delete</a></li>ntt</ul>nt</td>n</tr>”;
[/code]

Output

[code]
</td>
<td>
<ul>
<li>Edit</li>
<li><a title=”Delete this design” onclick=”delete(this, ” yes=”” )=”” href=”#”>Delete</a></li>

</ul>
</td>
</tr>
[/code]

On a side note, if I delete the backslashed quotes around “yes” the random “)=” shows up later in the output.

I’m clueless

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJul 14.2008 — Simplest fix I see would be to chage the escaped double quotes around "yes" ("yes") to un-escaped single quotes ('yes').

PS: You left out the closing quote after the onclick event.

A cleaner way might be to use HEREDOC quoting:
[code=php]
echo <<<END

</td>
<td>
<ul>
<li>Edit</li>
<li><a title="Delete this design" onclick="delete(this, 'yes')" href="#">Delete</a></li>
</ul>
</td>
</tr>
END;

// make sure there are no spaces/tabs before or after the "END;"
[/code]
Copy linkTweet thisAlerts:
@DJRobThaManauthorJul 14.2008 — Woops. I've been deleting and inserting all sorts of quotes to figure out what the problem was. Added the end quote after the onclick and it was still a problem, but changed the escaped quotes to single quotes like you suggested and it worked. Really weird.

Anyway, thanks a lot
×

Success!

Help @DJRobThaMan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...