Sublime Forum

Bug: PHP cli scripts are not highlighted

#1

I have a few PHP cli scripts that looks like this

#!/usr/bin/env php

function blabla()
{
     ...
}

blabla();

Sublime detected them as PHP script but all text are white.

Then I changed the script to something like this

#!/usr/bin/env php
# <?php

function blabla()
{
     ...
}

blabla();

Now syntax highlight worked. Looks like a bug to me.

0 Likes

#2

please can you log this at https://github.com/sublimehq/Packages/issues

I suspect the first part of the first_line_match from https://github.com/sublimehq/Packages/blob/cdf9fe3b02a9f70e1528ab0e571f858fd0a8647a/PHP/PHP.sublime-syntax#L13 needs to be moved to https://github.com/sublimehq/Packages/blob/ec221cb837b24bd15297f645b1bdc2ec0d28260f/PHP/PHP%20Source.sublime-syntax

0 Likes

#3

For the official PHP interpreter, everything not inside a <?PHP ?> tag is treated as HTML.

In the above screenshot, if what you write is PHP code, it should only print xd.
So in this case, I don’t think the highlighting is wrong.

2 Likes

#4

Ah, my bad.

Looks like the parse is correct after all … case closed.

0 Likes