本文介紹了PHPUnit 錯誤“未定義索引:HTTP_HOST";的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我已經聲明了一個 HTTP_HOST,如下所示.
I have declared a HTTP_HOST as shown below.
public function testReadUser() {
$_SERVER['HTTP_HOST'] = "x.y";
.
.
.
}
盡管如此,phpunit 給出了未定義的索引錯誤.為什么?
Inspite of this, phpunit gives undefined index error. Why is it?
推薦答案
在您的 phpunit.xml
文件中,您可以設置服務器變量.在 phpunit
根目錄下添加 php
元素:
In your phpunit.xml
file, you can set server variables. Add the php
element under the phpunit
root:
<phpunit>
<php>
<server name='HTTP_HOST' value='http://localhost' />
</php>
</phpunit>
有關詳細信息,請參閱文檔.
See the docs for more information.
這篇關于PHPUnit 錯誤“未定義索引:HTTP_HOST";的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!