Re: [PHP] location of the PHP executable
- From: mattias@xxxxxxxxxxxx (Mattias Thorslund)
- Date: Wed, 11 Apr 2007 15:17:17 -0700
Jim Lucas wrote:
Mattias Thorslund wrote:
Hi,
I have looked in the documentation but can't find it:
My PHP script (which is run from the command prompt - CLI) needs to know
the file system location of the PHP executable. This is because it needs
to run a second PHP script. I know about the "which" command but it's
not available in all OSes, and that might not be the currently running
executable anyway.
I could prompt the user for this, but that seems kind of silly. Surely,
there must be some way of looking it up automatically?
Thanks,
Mattias
What OS are you working with
Assuming you are on a *nix box this should work
#locate "/php" | grep "/php$"
this should give you locations that have /php as the end of the line
on windows you could do this
cd \
dir /s php*.exe
Thanks Jim (and others) for the suggestions. I think they will be helpful if there
isn't a way to do what I'm looking for:
Ideally, I would like to get the location of the PHP executable that is
actually executing the script. I'm thinking there would be some way to
find out while the script is executing. Something like:
<?php
$executable_location = get_location_of_current_executable();
//fictitious function
echo $executable_location ."\n";
?>
Running it from the command line (again fiction):
$ /my-location-of/php myscript.php
/my-location-of/php
$
I was hoping there's a function or $_SERVER property that would contain
this?
Thanks again,
Mattias
.
- Follow-Ups:
- Re: [PHP] location of the PHP executable
- From: Jochem Maas
- Re: [PHP] location of the PHP executable
- References:
- location of the PHP executable
- From: Mattias Thorslund
- Re: [PHP] location of the PHP executable
- From: Jim Lucas
- location of the PHP executable
- Prev by Date: Re: PHP textbook suggestions?
- Next by Date: RE: [PHP] location of the PHP executable
- Previous by thread: Re: [PHP] location of the PHP executable
- Next by thread: Re: [PHP] location of the PHP executable
- Index(es):
Relevant Pages
|
|