我在运行哪个PHP? [英] Which PHP am I running?

查看:52
本文介绍了我在运行哪个PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法确定php可执行文件的路径(而不是脚本的
。换句话说,我正在寻找php.exe的路径或

php-win.exe)当前正在运行(即。这个脚本是如何调用的)

在Windows上(我在Win XP Pro上)? WScript / CScript(在

VBScript中编程时)允许这样做。


如果做错了,有没有办法确定是否

正在运行的脚本是从php.exe还是php-win.exe调用的?我最后说

,因为

环境变量经常会略有不同,但不一定是这样。


谢谢,

来自纽约的Csaba Gabor

Is there a way to determine the path to the php executable (as opposed
to the script. In other words, I am looking for the path to php.exe or
php-win.exe) that is currently running (ie. how was this script called)
on Windows (I''m on Win XP Pro)? WScript/CScript (when programming in
VBScript) allow this, for example.

Failing that, is there any way to conclusively determine whether the
script that is running was invoked from php.exe or php-win.exe? I say
conclusively, because often there is a slight difference in the
environment variables, but it need not be the case.

Thanks,
Csaba Gabor from New York

推荐答案

Csaba Gabor写道:
Csaba Gabor wrote:

有没有办法确定php可执行文件的路径(而不是

到脚本。换句话说,我正在寻找路径到php.exe或

php-win.exe)当前正在运行(即。这个脚本是如何调用的)

在Windows上(我在Win XP Pro上) )? WScript / CScript(在

VBScript中编程时)允许这样做。


如果做错了,有没有办法确定是否

正在运行的脚本是从php.exe还是php-win.exe调用的?我最后说

,因为

环境变量经常会略有不同,但不一定是这样。


谢谢,

来自纽约的Csaba Gabor
Is there a way to determine the path to the php executable (as opposed
to the script. In other words, I am looking for the path to php.exe or
php-win.exe) that is currently running (ie. how was this script called)
on Windows (I''m on Win XP Pro)? WScript/CScript (when programming in
VBScript) allow this, for example.

Failing that, is there any way to conclusively determine whether the
script that is running was invoked from php.exe or php-win.exe? I say
conclusively, because often there is a slight difference in the
environment variables, but it need not be the case.

Thanks,
Csaba Gabor from New York



运行phpinfo()应该告诉你它是作为模块还是cgi运行。我相信它也有路径信息。
相信它也有路径信息。可能至少有一个路径变量目录的
。除非这一切,你可以使用脚本或exec()调用来搜索文件系统

Running phpinfo() should tell you if its running as a module or cgi. I
believe it also has path information. It is probably in at least one
of the directories of the path variables. Barring all that, you could
search the file system with a script or exec() call


Richard Levasseur写道:
Richard Levasseur wrote:

Csaba Gabor写道:
Csaba Gabor wrote:

有没有办法确定php可执行文件的路径(相反)

到脚本。换句话说,我正在寻找当前正在运行的php.exe或

php-win.exe的路径(即。这个脚本在Windows上叫做

(我在Win XP Pro上)? WScript / CScript(在

VBScript中编程时)允许这样做。


如果做错了,有没有办法确定是否

正在运行的脚本是从php.exe还是php-win.exe调用的?我最后说

,因为

环境变量经常会略有不同,但不一定是这样。
Is there a way to determine the path to the php executable (as opposed
to the script. In other words, I am looking for the path to php.exe or
php-win.exe) that is currently running (ie. how was this script called)
on Windows (I''m on Win XP Pro)? WScript/CScript (when programming in
VBScript) allow this, for example.

Failing that, is there any way to conclusively determine whether the
script that is running was invoked from php.exe or php-win.exe? I say
conclusively, because often there is a slight difference in the
environment variables, but it need not be the case.



感谢您的回复:

Thanks for your response:


运行phpinfo()应该告诉您它是否是作为模块或cgi运行。
Running phpinfo() should tell you if its running as a module or cgi.



是的。更简单的是php_sapi_name()[或PHP_SAPI],当我将php作为Web服务器模块运行时,它产生了
apache2handler。但是它显示了同样的事情,当从命令行启动php时

php.exe与php-win.exe:cli。如果我尝试使用

php-cgi尝试相同的事情,那么我得到:cgi-fcgi


所以这就是为什么剩下的问题是差异化的在php.exe之间

与php-win.exe

Yes. And easier is php_sapi_name() [or PHP_SAPI], which produces
apache2handler when I''m running php as a web server module. But it
shows me the same thing when php is started from the command line with
either php.exe vs. php-win.exe: cli. If I try try the same thing with
php-cgi, then I get: cgi-fcgi

So that''s why the remaining problem is differentiating between php.exe
vs. php-win.exe


我相信它也有路径信息。
I believe it also has path information.



phpinfo()显示PATH环境变量。它没有显示可执行文件的

路径,也没有显示可执行文件名。

phpinfo() shows the PATH environment variable. It does not show the
path to the executable, nor does it show the executable name.


它可能至少有一个

路径变量的目录。
It is probably in at least one
of the directories of the path variables.



我同意它可能是。但即使在这个假设下,如何以编程方式区分php.exe与php-win.exe之间的对比?

I agree that it probably is. But even under that assumption, how do
you programatically differentiate between php.exe vs. php-win.exe?


除此之外,你可以用脚本搜索文件系统或exec()调用
Barring all that, you could search the file system with a script or exec() call



你能详细说明一下 - 这怎么能让我确定被叫的

可执行文件?


Csaba

Could you elaborate, please - How does this let me determine the called
executable?

Csaba


Csaba Gabor写道:
Csaba Gabor wrote:

有没有办法确定php可执行文件的路径(而不是脚本的
。换句话说,我正在寻找php.exe的路径或<当前正在运行的(即。这个脚本是如何调用的)

在Windows上(我在Win XP Pro上)?例如,WScript / CScript(在

VBScript中编程时)允许这样做。
Is there a way to determine the path to the php executable (as opposed
to the script. In other words, I am looking for the path to php.exe or
php-win.exe) that is currently running (ie. how was this script called)
on Windows (I''m on Win XP Pro)? WScript/CScript (when programming in
VBScript) allow this, for example.



据我所知,除非你加载COM对象,否则没办法。

As far as I know there is no way, unless you load in a COM object.


如果失败了,有没有办法确定是否从php.exe或php-win.exe调用正在运行的

脚本?我最后说

,因为

环境变量经常会略有不同,但不一定是这样。
Failing that, is there any way to conclusively determine whether the
script that is running was invoked from php.exe or php-win.exe? I say
conclusively, because often there is a slight difference in the
environment variables, but it need not be the case.



不,php.exe和php-win.exe之间的唯一区别是

控制台窗口是否打开,你可以没有以编程方式检测到。

No, the only difference between php.exe and php-win.exe is whether a
console window opens or not and you can''t detect that programmatically.


这篇关于我在运行哪个PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆