在命令提示符或浏览器下运行的脚本或其他一些应用程序? [英] Script running under Command Prompt or Browser or some otherapplication?

查看:68
本文介绍了在命令提示符或浏览器下运行的脚本或其他一些应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!,


我只是出于好奇而想知道如何顶级检测客户端

应用程序,脚本运行在该应用程序之下。我的意思是询问

如何知道脚本是在命令提示符下运行还是

浏览器或其他一些应用程序?


Ojas。

解决方案

11月27日晚上9点34分,Ojas< contacto ... @ gmail.comwrote:
< blockquote class =post_quotes>
>

我只是出于好奇而想知道如何顶部检测

客户端应用程序下的脚本

正在运行。我的意思是问如何知道脚本是在命令提示符或浏览器

或其他一些应用程序下运行的?



这是不可能的。有可能知道哪个PHP

解释器(服务器模块,CGI,命令行等)正在处理

当前脚本:

http://www.php.net/ manual / en / function.php-sapi-name.php

对于请求脚本的客户端应用程序,客户端是

没有义务表明自己的身份。如果它确实标识了自己

(通过发送User-Agent:请求标头),则在该标题中发送的数据

将作为


_SERVER [" HTTP_USER_AGENT"]。


干杯,

NC


11月28日上午5:34,Ojas< contacto ... @ gmail.comwrote:


嗨!,


我只是出于好奇而想知道如何顶级检测客户端

应用程序,脚本运行在该应用程序之下。我的意思是询问

如何知道脚本是在命令提示符下运行还是

浏览器或其他一些应用程序?


Ojas。



是的,当从命令行运行php脚本时,两个变量


Hi!,

I just out of curiosity want to know how top detect the client side
application under which the script is getting run. I mean to ask the
how to know whether the script is running under Command Prompt or
Browser or some other application?

Ojas.

解决方案

On Nov 27, 9:34 pm, Ojas <contacto...@gmail.comwrote:

>
I just out of curiosity want to know how top detect
the client side application under which the script
is getting run. I mean to ask the how to know whether
the script is running under Command Prompt or Browser
or some other application?

This is not exactly possible. What is possible is knowing which PHP
interpreter (server module, CGI, command line, etc.) is processing the
current script:

http://www.php.net/manual/en/function.php-sapi-name.php

As to the client-side application requesting the script, the client is
under no obligation to identify itself. If it does identify itself
(by sending a "User-Agent:" request header), data sent in that header
are made available to the script as


_SERVER["HTTP_USER_AGENT"].

Cheers,
NC


On Nov 28, 5:34 am, Ojas <contacto...@gmail.comwrote:

Hi!,

I just out of curiosity want to know how top detect the client side
application under which the script is getting run. I mean to ask the
how to know whether the script is running under Command Prompt or
Browser or some other application?

Ojas.

Yep, when a php script is run from the commandline, the two variables


这篇关于在命令提示符或浏览器下运行的脚本或其他一些应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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