note 97684 added to function.get-headers

From: Date: Mon, 03 May 2010 00:28:29 +0000
Subject: note 97684 added to function.get-headers
Groups: php.notes 
Request: Send a blank email to php-notes+get-168877@lists.php.net to get a copy of this message
Seems like there are some people who are looking for only the 3-digit HTTP response code - here is a quick and nasty solution: <?php function get_http_response_code($theURL) { $headers = get_headers($theURL); return substr($headers[0], 9, 3); } ?> How easy is that? Echo the function containing the URL you want to check the response code for, and voilà. Custom redirects, alternative for blocked is_file() or flie_exists() functions (like I seem to have on my servers) hence the cheap workaround. But hey - it works! Pudding ---- Server IP: 87.124.86.46 Probable Submitter: 86.154.236.17 (proxied: 86.154.236.17) ---- Manual Page -- http://www.php.net/manual/en/function.get-headers.php Edit -- https://master.php.net/note/edit/97684 Del: integrated -- https://master.php.net/note/delete/97684/integrated Del: useless -- https://master.php.net/note/delete/97684/useless Del: bad code -- https://master.php.net/note/delete/97684/bad+code Del: spam -- https://master.php.net/note/delete/97684/spam Del: non-english -- https://master.php.net/note/delete/97684/non-english Del: in docs -- https://master.php.net/note/delete/97684/in+docs Del: other reasons-- https://master.php.net/note/delete/97684 Reject -- https://master.php.net/note/reject/97684 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#168877) next »