gpt4 book ai didi

php - 为什么 Zend_Http_Response 将状态码除以 100

转载 作者:可可西里 更新时间:2023-11-01 16:30:23 25 4
gpt4 key购买 nike

我一直看到开发人员在 Zend 中的一些代码之后进行模式化,我试图弄清楚为什么 Zend 可能以这种方式实现 http 响应代码检查:

/**
* Check whether the response in successful
*
* @return boolean
*/
public function isSuccessful()
{
$restype = floor($this->code / 100);
if ($restype == 2 || $restype == 1) { // Shouldn't 3xx count as success as well ???
return true;
}

return false;
}

具体来说,为什么他们会这样做而不是

public function isSuccessful()
{
return $this->code >= 100 && $this->code < 300
}

最佳答案

也许是因为他们只是在乎

5 03

4 04

4 01

3 02

2 01

等等,基本上对errortype的类不感兴趣

关于php - 为什么 Zend_Http_Response 将状态码除以 100,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25205680/

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