.. granted you'd normally want to have a *.js file for your JS code but if you had to spew out a whole lot of JS code in PHP here is a easy way using lables and raw format :
function echoJavascript(){
$jscode= <<<MY_JS
<script type="text/javascript">
blah blah blah... your javascript code here
</script>
MY_JS;
echo $jscode;
}