Yii::writeJavaScript("mayBeAnExistingJavaScriptFunction($someValuefromPHP)");
Yii::writeJavaScript("console.log($someValuefromPHP)");
// or simple call an existing javascript function
Yii::writeJavaScript("callThatFunctionNow()");
I would like to shorten following statement (within a view):
echo "
<script type='text/javascript'>
// do something
console.log($myPHPVariable);
</script>
";
I’m not sure if I’m completely understanding, but look at CClientScript::registerScript(). You can use it to insert javascript code into various parts of your completed page.
You could write your own wrapper function to output the tags, but it’s probably better for readability to leave them in the view. You’ll also get syntax highlighting from your editor by writing the script directly in the view.
Is it really so difficult to understand? But by the way, you must not understand my intention, it is more than enough to read: "No there is not such a function". There is unfortunately plenty of OReys on this planet…
But many thanks for all the well-intentioned advices…