+
80
-

php中http_response_code(404)与header('HTTP/1.1 404 Not Found')header("status: 404 Not Found")区别?

php

请问php中http_response_code(404)与header('HTTP/1.1 404 Not Found')header("status: 404 Not Found")区别?

网友回复

+
0
-

php 5.4版本之前404的输出都是通过headerr()方法来实现;

<?php;
header('HTTP/1.1 404 Not Found');
header("status: 404 Not Found");
?>
5.4之后的版本新增了一个内置方法叫做http_response_code(),两者效果是一样的;
<?php
http_response_code(404);
?>

+
0
-

通过parse_str函数来实现,代码如下:

<?php
$url = "name=tom&sex=1&channel=ty";
parse_str($url, $query_arr);
print_r($query_arr);

我知道答案,我要回答