A quick guide to embedding newlines, quotes and tick marks inside a JavaScript statement using PHP.
About
This is a demonstration of how to embed new lines and tick marks inside a javascript function using PHP. Dealing with quotes and escaped characters can be very confusing when building dynamic scripts. The example below gives a web programmer an idea of how it should be done in order for it to work properly.
Example
This is an example PHP script which displays a JavaScript confirm() dialog box that has quotes and apostrophies inside it.
<?php
echo <<<EOT
<form method=POST><input type=submit name=payment value='Accept Offer' onClick="return confirm("This text has newlines.\\nIt and 'apostrophies'.\\n\\nPress 'OK' to accept the offer.\\nPress 'Cancel' to go back without submitting any changes.\\n");" /></form>
EOT;
?>
Conclusion
I hope the example helped you out.
Credits
Special thanks to brainy on the #javascript IRC channel for helping me figure this out. We can now hide javascript inside a link instead of making a function.