CRON Job中的PHP标头不起作用 [英] PHP Header in CRON Job not working
问题描述
我正在使用此代码 header(’位置:http://example.com/test.php?number=’.$requestsDone。’);
但是看起来好像没有用,这是怎么回事?
But looks like it is not working, what is wrong here?
如果您需要更多信息,请告诉我。
Let me know, if you need more information.
推荐答案
在命令行脚本中产生标题没有任何意义。标头是HTTP协议的一部分,使用 PHP的CLI版本。
Producing a header in a command line script doesn't make any sense. The header is part of the HTTP protocol, there is no HTTP involved when the script is executed using the CLI version of PHP.
因此, header()
函数未在PHP的CLI版本中实现。它存在,但是它不会产生任何输出。
此外,超全局变量,其中包含从HTTP请求中提取的信息( $ _ GET []
, $ _ POST []
, $ _ REQUEST []
, $ _ FILES []
, $ _ COOKIE []
等)存在,但它们为空。
Also, the superglobals that contain information extracted from the HTTP request ($_GET[]
, $_POST[]
, $_REQUEST[]
, $_FILES[]
, $_COOKIE[]
etc) exist but they are empty.
为了使用命令行将参数传递给脚本,请使用 $ argc
和 $ argv []
变量。
In order to pass arguments to a script using the command line, use the $argc
and $argv[]
variables.
这篇关于CRON Job中的PHP标头不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!