Jump to content


Photo

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


  • Please log in to reply
2 replies to this topic

#1 phpfreak101

phpfreak101
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 26 July 2006 - 01:36 AM

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
echo "<a href='blah.com' onclick = 'function(
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

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 26 July 2006 - 01:47 AM

escape quotes somewhere in the string, e.g. echo "<a href=\"blah.com\" ...
Legend has it that reading the manual never killed anyone.
My site

#3 Joe Haley

Joe Haley
  • Members
  • PipPipPip
  • Advanced Member
  • 103 posts
  • LocationCanada, eh?

Posted 26 July 2006 - 02:01 AM

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;

Will also work.
(from the PHP manual)
Give a man a fish; you have fed him for today.  Teach a man to fish; and you have fed him for a lifetime
Don't teach men to program. Teach them to fish.

Please, try the RTFM solution before asking for help:
http://php.net/manual/en/index.php




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users