note 88859 added to function.file-exists

From: Date: Wed, 11 Feb 2009 11:27:56 +0000
Subject: note 88859 added to function.file-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-150475@lists.php.net to get a copy of this message
Hi! There were a solution with @get_headers in one post below, but I thing here is a better one function, because in this example is a timeout solution included! <?php function checkFile($url, $timeout = 3) { $ch = curl_init ($url) ; curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true) ; curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true ); curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, 'HEAD'); curl_setopt ($ch, CURLOPT_TIMEOUT, $timeout ); curl_setopt ($ch, CURLOPT_HEADER, true ); $res = curl_exec ($ch) ; curl_close ($ch); if ($res !== false && preg_match("|200|", $res) === 1) { return ((bool) true); } else { return ((bool) false); } } ?> ---- Server IP: 217.13.201.10 Probable Submitter: 213.61.32.141 ---- Manual Page -- http://www.php.net/manual/en/function.file-exists.php Edit -- https://master.php.net/note/edit/88859 Del: integrated -- https://master.php.net/note/delete/88859/integrated Del: useless -- https://master.php.net/note/delete/88859/useless Del: bad code -- https://master.php.net/note/delete/88859/bad+code Del: spam -- https://master.php.net/note/delete/88859/spam Del: non-english -- https://master.php.net/note/delete/88859/non-english Del: in docs -- https://master.php.net/note/delete/88859/in+docs Del: other reasons-- https://master.php.net/note/delete/88859 Reject -- https://master.php.net/note/reject/88859 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#150475) next »