You can use heredoc syntax:
$javascript = <<<EOT
//Enter javascript here
EOT;
Within the heredoc syntax, you can enter single and double quotes. The syntax starts with '<<<' and a unique identifier (in this case 'EOT') that appears nowhere else on you page, and it closes with the same identifIer and a semicolon. It's important that no spaces or anything else occur on the same line as the closing identifier.
For example, you could do the following:
$javascript = <<<EOT
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
alert("Hello world!");
});
//]]>
</script>
EOT;