CRON Job中的PHP标头不起作用 [英] PHP Header in CRON Job not working

查看:68
本文介绍了CRON Job中的PHP标头不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此代码 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屋!

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