Highlighting js-code inside php file
If you use the hard-coded "JS" heredoc, it'll know it's Javascript and give you autocomplete for that snippet:
$javascript_code = <<<JS
function test(){
console.log('hello!');
}
JS;
Settings | Template Data Languages -- find your file(s) or folder(s) and assign JavaScript
to them (instead of default HTML).
If you keep your stuff well organized, then you will benefit from keeping all *.js.php
files under separate subfolder -- this allows single assignment for a whole folder (and all files inside) instead of multiple assignments for individual files.
- Put your cursor on the JavaScript part
- Press
Alt + Enter
- Select
Inject Language
- Select
JavaScript
For example:
<?php
echo "<script>/* CURSOR HERE*/
alert('Hello World');
</script>";