Re: location of the PHP executable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux