问题
I am unfamiliar with how Sublime Text 3 uses syntax highlighting, as in, if it purely relies on the theme or has it's built in standard that themes run off of but in my case, there's some syntax highlighting discrepancy with using PHP's HERE docs and forward slashes. Once a forward slash is present, it appears ST3 thinks all the following code is apart of that tag.
Is this something I can fix?
Forward slash syntax highlighting discrepancy
No forward slash and correct syntax highlighting
回答1:
Because your HEREDOC is called JAVASCRIPT
, Sublime Text is trying to syntax highlight the contents as JavaScript.
But because you are including HTML (the <script>...</script>
tag), it highlights it incorrectly (it seems to think it is a regular expression and thus doesn't find/expect the HEREDOC to end until (what it thinks is) the regex does.).
The fix is simply to change your code to name the HEREDOC as HTML
instead:
<?php
$inlineJS =
<<<HTML
<script>
$('ele').click(function(){
// some code
});
</script>
HTML;
?>
来源:https://stackoverflow.com/questions/40124576/phps-here-doc-eot-syntax-highlighting-discrepancy-with-forward-slash-on-subli