Re: location of the PHP executable

From: Date: Thu, 12 Apr 2007 00:57:21 +0000
Subject: Re: location of the PHP executable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-252659@lists.php.net to get a copy of this message
On Wed, April 11, 2007 2:49 pm, Mattias Thorslund wrote: > 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? The generalized answer to any question of this nature is: If the answer you want isn't in <?php phpinfo();?> output, then the answer you want probably isn't available. In *my* installation: which php yields: /usr/bin/php Then: php -i | grep "/usr/bin/php" yields $_SERVER["_"] and $_ENV["_"] No promise this works for any/all platforms, however. PS For the 'locate' sub-thread -- You can't even guarantee that 'locate' will be available, much less initialized... I don't think it's a good solution, in general. YMMV NAIAA IANAL -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?

« previous php.general (#252659) next »