How can I set the PHP version in PHPStorm?

Fluffy picture Fluffy · Nov 8, 2010 · Viewed 85k times · Source

Is it possible to set the PHP version value, say 4.0+ and have PHPStorm highlight functions that wouldn't work with the oldest version? For example, for PHP4 this should highlight static function etc. I have a PHP installation on my PC but I don't want to install an older PHP version for every small script I have to produce.

Thanks

Answer

Alejandro Moreno picture Alejandro Moreno · Sep 10, 2014

So, you mean to highlight all pieces of code that will not work with the PHP version you are writing it in, right? That can be done here:

Preferences -> Languages & Frameworks > PHP

and the same on Mac:

PhpStorm -> Preferences (⌘,) -> Languages & Frameworks > PHP

Or with newer versions of PhpStorm in Windows:

File -> Settings -> Languages & Frameworks > PHP

Sample dialogbox for mentioned prefrences

then select your PHP version, for example, 7.0

This is very useful when your local system runs PHP 7.0, for example, but production is running PHP 5.5.

That way PhpStorm will warn you which parts will not work in production, show proper hints during writing code according to the selected version, etc.