Reply to Re: how to discover PHP interpreter name in a script

Your name:

Reply:


Posted by petersprc on 03/22/07 09:25

On Windows, you could use getmypid and the Windows Management
Interface COM object to get informatino about the current process like
so:

<?

function getWinPhpPath()
{
$path = false;
if (!($mgmt = new COM("winmgmts:"))) {
trigger_error("Failed to create management object.",
E_USER_ERROR);
} else {
$procs = $mgmt->ExecQuery("select * from Win32_Process where " .
"ProcessId = " . getmypid());
if ($proc = $procs->Next()) {
$path = $proc->ExecutablePath;
} else {
trigger_error("Failed to retrieve process information.",
E_USER_ERROR);
}
}
return $path;
}

echo "The executable path is: \"" . getWinPhpPath() . "\".";

?>

If it doesn't work, you could spawn a wsh script that does the same
thing, but get the path of the parent process.

As an alternative, you could try guessing the path based on the
extensions dir:

<?

function guessPhpExe()
{
$ret = false;
$extDir = ini_get('extension_dir');
if ($extDir === false) {
trigger_error("No extension dir.", E_USER_ERROR);
} else {
$path = dirname($extDir) . '/php.exe';
if (file_exists($path)) {
$ret = $path;
}
}
return $ret;
}

?>

On Mar 21, 8:23 pm, "Dan Fulbright" <dfulbri...@gmail.com> wrote:
> How can I find the name of the PHP interpreter (i.e., C:\PHP\php-
> cgi.exe) from a PHP script? I looked through all the functions on the
> PHP options & information page:http://us2.php.net/manual/en/ref.info.php
> but couldn't find anything. I'm using PHP 4 as CGI in IIS on a Windows
> 2000 server.
>
> Thanks in advance.
>
> --
> Dan Fulbright
> Broken Arrow, Oklahoma, USA

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация