Skip to content

Instantly share code, notes, and snippets.

@scottdavis
Created December 10, 2009 05:34
Show Gist options
  • Save scottdavis/253141 to your computer and use it in GitHub Desktop.
Save scottdavis/253141 to your computer and use it in GitHub Desktop.
<?php
private static function find_executable() {
$filename = basename(pathinfo(__FILE__, PATHINFO_FILENAME));
if(isset($_SERVER['_']) && substr(basename($_SERVER['_']), -1 * strlen($filename)) != $filename) {
return $_SERVER['_'];
}
$seperator = ':';
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {$seperator = ';';}
$path = explode($seperator, $_SERVER["PATH"]);
foreach($path as $_path) {
$test = $_path . DIRECTORY_SEPARATOR . 'php';
if(file_exists($test) || file_exists($test . '.exe')) {
return $test;
}
}
throw new Exception("no php executable found");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment