How to programmatically check if running on HHVM?

前端 未结 2 663
孤街浪徒
孤街浪徒 2020-12-30 00:11

I need to run a given package on both HHVM runtime and traditional PHP runtime. My question: is there a way to check programmatical

相关标签:
2条回答
  • 2020-12-30 00:26

    Some older versions of HHVM don't have HHVM_VERSION defined. They all output "HipHop" in phpinfo().

    function is_hhvm(){
      ob_start();
      phpinfo();
      $info=ob_get_contents();
      ob_end_clean();
      return ($info=='HipHop');
    }
    
    0 讨论(0)
  • 2020-12-30 00:51

    You can utilise the constant HHVM_VERSION specific to HHVM:

    if (defined('HHVM_VERSION')) {
        // Code
    }
    

    You can put this in your own function if you want.

    function is_hhvm() {
        return defined('HHVM_VERSION');
    }
    
    if (is_hhvm()) {
        // Code
    }
    

    Source: http://www.hhvm.com/blog/2393/hhvm-2-3-0-and-travis-ci

    0 讨论(0)
提交回复
热议问题