When I use php variable variables for JavaScript variables, I get the "expected expression" from PhpStorm.
I cannot change the file extension to something.js.php, because I already use the blade server template, so it should beblade.php


<!DOCTYPE html>
<html>
<body>
<?php $myVar = 5;?>
<script type="text/javascript">
var myJavascriptVar = <?php echo $myVar; ?>;
var myJavascriptSecondVar = {{$myVar;}};
alert(myJavascriptVar + myJavascriptSecondVar);
</script>
</body>
</html>
Run codeHide resultI added a sample html page for more details. In phpstrom
and
Operatorsexpress the expected error.
source
share