php代码
<?php
final class HttpDownload {
public static $filesize;
public static $Downloadstatus = FALSE;
private static function getfilesize($url) {
$headers = get_headers($url, 1);
if($headers[0] == 'HTTP/1.1 200 OK') {
if(isset($headers['Content-Length'])) {
return self::$filesize = (int)$headers['Content-Length'];
}
}
return self::$filesize = (int)0;
}
public static function save2dir($url, $localname, $forcibly = TRUE) {
$filesize = self::getfilesize($url);
if(is_resource(@fopen($url, 'r'))) {
set_time_limit(0);
if($forcibly) {
if(file_exists($localname)) unlink($localname);
}
copy($url, $localname);
return self::$Downloadstatus = (bool)true;
}
return self::$Downloadstatus = (bool)false;
}
}
HttpDownload::save2dir('http://www.baidu.com/index.html', 'baidu.html');
if(HttpDownload::$Downloadstatus) {
echo 'success';
}else{
echo 'failed';
}
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号