Jump to content

Archived

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

phpfreak101

What to do when you run out of parameter notations? ie. " and '

Recommended Posts

Okay.. what do i do in a situation such as this..

Lets say you echo an HTML tag and inside the "onclick event, you want to call a javascript function and pass a variable to it.

you end up like this
[code]
echo "<a href='blah.com' onclick = 'function(
[/code]
Now this is where i'm stuck if i use ' it closes my onclick block of code and if i use " it closes my echo block of code

Share this post


Link to post
Share on other sites
escape quotes somewhere in the string, e.g. echo "<a href=\"blah.com\" ...

Share this post


Link to post
Share on other sites
[code=php:0]
echo <<<END
This uses the "here document" syntax to output
multiple lines with $variable interpolation. Note
that the here document terminator must appear on a
line with just a semicolon. no extra whitespace!
END;
[/code]

Will also work.
(from the PHP manual)

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.