473,394 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how to discover PHP interpreter name in a script

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

Mar 22 '07 #1
1 3637
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.comwrote:
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

Mar 22 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Stephen VanDahm | last post by:
I'm looking for a way to install Python on a UNIX machine in a way such that any user on the system can use it, but only to execute scripts that are located in a certain directory. I do not have...
16
by: Neil Benn | last post by:
Hello, I'm looking at a small app which would need a very quick startup time for the Python interpreter. It doesn't do much (copying and caching of files, no GUI) but I need the Python...
4
by: Ian Giblin | last post by:
I am an experienced C programmer, learning C++ by writinging a mathematical toolkit in the framework of a script interpreter. I am posting here to ask for advice (or references) on the object...
6
by: harish | last post by:
Hi, We are developing one application for smartphone. In this we are parsing XMLs and rendering it as UI elements using smartphone SDK. Everything is working fine. Now one more requirement has...
6
by: Alan Isaac | last post by:
I'm fairly new to Python and I've lately been running a script at the interpreter while working on it. Sometimes I only want to run the first quarter or half etc. What is the "good" way to do...
5
by: Joel | last post by:
In the course of my project, I must include some custom logic and would like to integrate a small script language in my application for that purpose. In C++, I used the LUA script language and I...
7
by: JonathanB | last post by:
Ok, I know there has to be a way to do this, but my google-fu fails me (once more). I have a class with instance variables (or should they be called attributes, I'm newish to programming and get...
13
by: jkimbler | last post by:
As part of our QA of hardware and firmware for the company I work for, we need to automate some testing of devices and firmware. Since not everybody here knows C#, I'm looking to create a new...
16
by: lawrence k | last post by:
I've never before written a PHP script to run on my home Ubuntu machine (though I've written dozens of PHP cron jobs for my web server), so I thought I'd start off with a very simple test: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.