Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programmatically check if running on HHVM?

Tags:

I need to run a given package on both HHVM runtime and traditional PHP runtime. My question: is there a way to check programmatically if current environment is HHVM? Something like this:

<?php if(running_on_hhvm()) {     // do hhvm compatible routine } else {     // do normal routine } 
like image 645
marcio Avatar asked Dec 26 '13 00:12

marcio


1 Answers

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

like image 166
SamV Avatar answered Sep 24 '22 07:09

SamV