php – 获取标头响应代码
发布时间:2020-12-13 13:50:02 所属栏目:PHP教程 来源:网络整理
导读:这是我整理的 PHP脚本的一部分.基本上,域($domain1)在表单中定义,并根据服务器的响应代码显示不同的消息.但是,我遇到了让它运转的问题. 3位数的响应代码是我感兴趣的. 这是我到目前为止: function get_http_response_code($domain1) { $headers = get_heade
这是我整理的
PHP脚本的一部分.基本上,域($domain1)在表单中定义,并根据服务器的响应代码显示不同的消息.但是,我遇到了让它运转的问题. 3位数的响应代码是我感兴趣的.
这是我到目前为止: function get_http_response_code($domain1) { $headers = get_headers($domain1); return substr($headers[0],9,3); foreach ($get_http_response_code as $gethead) { if ($gethead == 200) { echo "OKAY!"; } else { echo "Nokay!"; } } } $domain1 = 'http://google.com'; function get_http_response_code($domain1) { $headers = get_headers($domain1); return substr($headers[0],3); } $get_http_response_code = get_http_response_code($domain1); if ( $get_http_response_code == 200 ) { echo "OKAY!"; } else { echo "Nokay!"; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |