gpt4 book ai didi

cakephp-2.0 - CakePHP 控制台给出错误 "Undefined index: HTTP_HOST"

转载 作者:行者123 更新时间:2023-12-05 01:48:06 32 4
gpt4 key购买 nike

我在 APP/Config/config.php 中有一个设置我有一行定义主机:

define('SITE_URL','http://'.$_SERVER['HTTP_HOST']);

每当我运行蛋糕控制台时,我都会收到错误:

Notice (8): Undefined index: HTTP_HOST [APP/Config/config.php, line 144]
Code Context
include - APP/Config/config.php, line 144
PhpReader::read() - CORE/Cake/Configure/PhpReader.php, line 80
Configure::load() - CORE/Cake/Core/Configure.php, line 267
include - APP/Config/bootstrap.php, line 190
Configure::bootstrap() - CORE/Cake/Core/Configure.php, line 92
require - CORE/Cake/bootstrap.php, line 146
ShellDispatcher::_bootstrap() - CORE/Cake/Console/ShellDispatcher.php, line 131
ShellDispatcher::_initEnvironment() - CORE/Cake/Console/ShellDispatcher.php, line 101
ShellDispatcher::__construct() - CORE/Cake/Console/ShellDispatcher.php, line 57
ShellDispatcher::run() - CORE/Cake/Console/ShellDispatcher.php, line 68
[main] - APP/Console/cake.php, line 33

为什么会出现这个问题,我该如何解决这个问题?

最佳答案

这是因为您是从控制台运行的,(cakePHP 使用 PHP-CLI)

$_SERVER['HTTP_HOST']

它仅在从浏览器(网络服务器)运行时填充

关于cakephp-2.0 - CakePHP 控制台给出错误 "Undefined index: HTTP_HOST",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18790739/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com