如何区分http和cli请求? [英] How to differentiate between http and cli requests?

查看:203
本文介绍了如何区分http和cli请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题很安静直截了当。我必须在服务器端知道脚本是通过HTTP请求还是通过命令行调用的。我可以检查 $ _ SERVER ['argv'] $ _ SERVER ['argc']

实用方式是什么?

The title is quiet straightforward. I have to know on server side if the script called through HTTP request or by command line. I could examine the $_SERVER['argv'] or $_SERVER['argc'].
What is the pragmatic way to do that?

推荐答案

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

<?php
echo PHP_SAPI;
echo php_sapi_name();
?>

这篇关于如何区分http和cli请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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