Search code examples
phpenvironmenthiphop

Detecting whether the program is run through HipHop or regular CLI/mod_php


I was wondering if anyone has found a way to detect whether a PHP script/program is run through Facebook's HipHop or the "regular" environment (CLI, mod_php, CGI).

Currently the workaround I am using is looking for an unimplemented feature (for instance PHP 5.3 functions) and checking for the availability of said feature. Of course, this is rather a dodgy hack (and not portable) since as HipHop matures, more and more features will be implemented.


Solution

  • $_ENV['HPHP'] is set to 1 when running under HipHop.

    Thanks to nicolasff for the solution

    Ref: https://github.com/facebook/hiphop-php/issues/382#issuecomment-1754648