<?php
$script = <<<JavaScript
var myvar = 1;
function test() {...}
...
JavaScript;
Yii::app()->getClientScript()->registerScript('id',$script);
This way I DO get syntax highlight in vim. Netbeans doesn’t support that though. But you DO get good variable substitution, same as in double quotes but no need to escape double quotes.
To be honest can’t see why you’d add js in the view any more anyway. Its much more convenient to have js in a single files to contend with duplicated code and the overhead is sorted by minifying it and compressing it.
Most application level js is moving towards this methodology anyways if you consider backbone with its views and routes and requirejs for on demand loading.