如何使PHP文件只能通过CLI模式运行? [英] how to make a PHP file run-able only through CLI mode?

查看:205
本文介绍了如何使PHP文件只能通过CLI模式运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它可用于浏览器,

但是我不希望它在用户浏览时执行

but I don't want it to execute when browsed by user,

说,当浏览时应该退出

有没有办法检测当前是否为命令模式?

is there a way to detect whether it's currently Cmmand Line Mode?

推荐答案

请参阅:

  • What is the canonical way to determine commandline vs. http execution of a PHP script?
  • Is there any way to know if a php script is running in cli mode?
  • PHP - what is the best & easy way to determine if the current invocation is from CLI or browser

短篇小说: php_sapi_name() .

Short story: php_sapi_name().

这篇关于如何使PHP文件只能通过CLI模式运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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