and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I've written a PHP function that takes in HTML code as its parameter.
In a file I pass in some code that displays a login form and I use javascript and essentially I run out of ways to parse quotes:
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Last edited by HiddenS3crets on Thu Jul 05, 2007 8:56 pm, edited 1 time in total.
Use the backslash to escape the same kind of quotes inside a string like you (unintentionally?) did with the highlighted double quotes in the code you posted. Alternativey you can try the heredoc-syntax.
As you can see that will close the alert function early, causing an error. That's basically the problem I'm having (I can't use single quotes around username either because I'm already using them; further more, parsing single quotes as \' doesn't work).
Last edited by HiddenS3crets on Thu Jul 05, 2007 7:40 pm, edited 1 time in total.
<?php
function function_name($string) { echo $string; }
function_name("
Login here: <a href='javascript:createPopup(\"
<!-- various html tags here -->
<input type=submit onClick=login(document.getElementsByTagName(\\\"username\\\").item(0).value) value=login />
\")'>login</a>
");
?>
Things changed: escaped \ and " where you wanted \", added a single quote to the end of <input ...> since it was missing.
I would never use anything like this myself though, it's just plain nasty.