Jump to content


Photo

unescaped XHTML as a variable?


  • Please log in to reply
1 reply to this topic

#1 cperkins

cperkins
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 29 September 2006 - 07:27 PM

I have a PHP document that has a small block of XHTML in it that I need captured in a PHP variable.  But, since this page needs to be relatively easy for end users to edit, I would prefer to not use escaped XHTML.

For example, this is what I want to avoid:

$myvar = "<p>some text<a href=\"go/home.html\" onclick=\"javascript:alert('hi');\">click me</a></p>"

I really need the XHTML to  have double quotes in it (for attributes), as well as single quotes and slashes, without them being escaped.  But I also need this block bound in a variable.

I could place the XHTML in an external file, unescaped, and just read the file. But I'm afraid this will confuse my end users, which won't know where to look for their text.


For a minute, I was hoping the Simple XML parser might do the trick:  <<<XML .... XML;  
Because, XHTML is valid XML, but it didn't seem to work and I'm having difficulty finding documentation about the <<<... special form itself.

Any guidance or insight appreciated. 

Chris Perkins

#2 cperkins

cperkins
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 29 September 2006 - 07:47 PM

found it.  It was the heredoc  quoting that I needed.

http://us3.php.net/types.string

I'm not sure why it wasn't working at first, but it is now, and all is well.

Chris




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users