刚刚发现在CodeProject给我推送了一篇文章叫:the Shortest PHP code for Returning HTTP Response Code 翻译过来就是(PHP最短的HTTP响应代码)当中作者用了13个例子来找最短的那个HTTP响应代码,其中有五个是没有成功的,下面是我在这篇文章中截到的内容:
header("HTTP/1.1 404"); //works header("HTTP/1 404"); //works header("HTTP/ 404"); //works header("HTTP 404"); //doesn't work, returns 200 OK header("HTTP/1.1",0,404); //doesn't work, returns 200 OK header("HTTP/1",0,404); //doesn't work, returns 200 OK header("HTTP/",0,404); //doesn't work, returns 200 OK header("HTTP",0,404); //works header("",0,404); //doesn't work, returns 200 OK header("/",0,404); //works header("1",0,404); //works header(1,0,404); //works header(0,0,404); //works
So Shortest Code is:
header(0,0,404);