PHP syntax highlighting not working without <?php

Hello,

PHP syntax highlighting works OK with PHP files that start with <?php, but it fails to happen when the <?php is not there! 

File types is correct, in Settings > Editor > File Types

I've also tried resetting cache with File > Invalidate Caches / Restart

Running on 

Windows 10
PhpStorm 2017.1.4 

Any ideas?

Thanks!

1
6 comments

Hi there,

It's a correct behaviour -- opening tag is required ... otherwise the content is treated as plain text/HTML.

Do you have short tag there (<? instead of <?php) ... or no tags at all?

In any case -- some clarification might be required (in case if I misunderstood your situation) -- screenshots/file samples etc.

0
Avatar
Permanently deleted user

I'm using no opening tag at all. Even though it is valid PHP code, I'm getting no highlighting/indentation whatsoever - it is treated as plain text. The files all have extension .php. Here's the screenshots:

Without opener:

With opener:

0

But .. PHP itself requires opening <?php tag ... otherwise it treats such file as plain text... (unless I'm missing something new from PHP config).

 In any case: PhpStorm does not have such option -- <?php is required to specify where PHP code starts.

0
Avatar
Permanently deleted user

OK thanks. I'm pretty new to PHP, and some of the ZF example code does not use the opening tag. Again, thanks.

0

Here is PHP execution results of the some test file -- as you can see the file was not interpreted by PHP as such -- it was treated as plain text so was sent to the output as is.

Surely, I can use "-r" option for PHP CLI Interpreter for some very simple code chunks .. but from what I see it does not work with files.

Maybe your ZF2 works differently (sorry, never used Zend Framework 2 myself ... only few individual components from ZF1)

0
Avatar
Permanently deleted user

Thanks for trying it, Andriy

0

Please sign in to leave a comment.