note 31024 added to ref.curl

From: Date: Mon, 07 Apr 2003 10:00:20 +0000
Subject: note 31024 added to ref.curl
Groups: php.notes 
Request: Send a blank email to php-notes+get-46304@lists.php.net to get a copy of this message
Here's a little code snippet if you need the last-modified-time for a remote file as filemtime() does not work on those. :) $modified = ""; function read_header($ch, $header) { global $modified; $length = strlen($header); if(strstr($header, "Last-Modified:")) { $modified = substr($header, 15); } return $length; } function last_mod($remote_file) { global $modified; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $remote_file); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_NOBODY, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'read_header'); $headers = curl_exec ($ch); curl_close ($ch); return $modified; } use something like echo strtotime(last_mod("http://www.php.net/")); to get the time as an Unix timestamp or echo last_mod("http://www.php.net/"); to get the gmdate()-like time. -- http://www.php.net/manual/en/ref.curl.php http://master.php.net/manage/user-notes.php?action=edit+31024 http://master.php.net/manage/user-notes.php?action=delete+31024 http://master.php.net/manage/user-notes.php?action=reject+31024

« previous php.notes (#46304) next »