簡體   English   中英

PHP:如何設置http響應代碼?

[英]PHP: How to set http response code?

我將wamp與PHP 5.5.12一起使用。 我正在嘗試使用http_response_code設置代碼。 使用它時,它返回true而不是我設置的值。 我是PHP新手,我想知道我在其中缺少什么。 我如何得到它返回300而不是真的?

getCode(300); // returns true and not with the code I set.

function getCode($code)
{
  $statuscode = http_response_code($code);
  echo $statuscode;
}

我建議您閱讀有關http_response_code的文檔: http : //php.net/manual/en/function.http-response-code.php

TRUE will be returned if response_code is provided and it is not invoked in a web server environment (but only when no previous response status has been set).

設置為true表示“好,我們會發送300”,因此對於您來說很好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM