Home >Backend Development >PHP Tutorial >How to get the remote file size class in php4_PHP tutorial

How to get the remote file size class in php4_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:08:15959browse

PHP5's get_headers is very useful because it can directly read the information of remote files without reading the entire file to the server. But now many web servers do not support php5. Let's take a look at an example class about php4 getting the file size of the remote server.

php tutorial 4 how to get the remote file size class
/*
PHP5 has get_headers which is very useful because it can directly read the information of the remote file without reading the entire file to the server. But now many web servers do not support php5. Let's take a look at an example class about php4 getting the file size of the remote server.
*/

if(!function_exists('get_headers'))
{
function get_headers($url,$format=0)
{
$ url=parse_url($url);
                                                                                                                                                                                                                                                                      url = parse_url($url); ['port']), $errno, $errstr, 30);
if ($fp)
{
$out = "get / http/1.1rn";
$out .= "host: ".$url['host']."rn";
                                                                                                                                          . ;
while (!feof($fp))
{
$var.=fgets($fp, 1280);
if(strpos($var,$end))
break ;
        }
                                                                                                                                                     rn",$var);
if($format)
{
foreach($var as $i)

If(preg_match('/^([a-za- z -]+): +(.*)$/',$i,$parts))

                                                                                       v,



http://www.bkjia.com/PHPjc/444899.html

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/444899.html

TechArticle

php5 has get_headers which is very useful because it can directly read the information of the remote file without reading the entire file. Get the server. But now many web servers do not support php5, below...


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn