<?php $filename = "/usr/local/something.txt"; $handle = fopen($filename, "r");//读取二进制文件时,需要将第二个参数设置成'rb' //通过filesize获得文件大小,将整个文件一下子读到一个字符串中 $contents = fread($handle, filesize ($filename)); fclose($handle); ?>
<?php
$handle = fopen('http://www.baidu.com', 'r');
$content = '';
while(!feof($handle)){
$content .= fread($handle, 8080);
}
echo $content;
fclose($handle);
?>
<?php
$handle = fopen('http://www.baidu.com', 'r');
$content = '';
while(false != ($a = fread($handle, 8080))){//返回false表示已经读取到文件末尾
$content .= $a;
}
echo $content;
fclose($handle);
?>
<?php
$handle = fopen('./file.txt', 'r');
while(!feof($handle)){
echo fgets($handle, 1024);
}
fclose($handle);
?>
<?php
$handle = fopen('./file.txt', 'r');
while(!feof($handle)){
echo fgetss($handle, 1024, '<br>');
}
fclose($handle);
?>
<?php
$a = file('./file.txt');
foreach($a as $line => $content){
echo 'line '.($line + 1).':'.$content;
}
?>
<?php
$size = readfile('./file.txt');
echo $size;
?>
<?php
$ctx = stream_context_create(array(
'http' => array(
'timeout' => 1 //设置超时
)
)
);
echo file_get_contents("http://www.baidu.com/", 0, $ctx);
?>
<?php
header("Content-Type:text/html;charset=utf-8");
$handle = fopen('./test2.php', 'r');
fseek($handle, 1024);//将指针定位到1024字节处
fpassthru($handle);
?>
; This is a sample configuration file ; Comments start with ';', as in php.ini [first_section] one = 1 five = 5 animal = BIRD [second_section] path = "/usr/local/bin" URL = "http://www.example.com/~username
<?php
$config = parse_ini_file('./test.ini', ture);
print_r($config);
?>
Array
(
[first_section] => Array
(
[one] => 1
[five] => 5
[animal] => BIRD
)
[second_section] => Array
(
[path] => /usr/local/bin
[URL] => http://www.example.com/~username
)
)
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-3 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2026 源码网商城 (www.yuanmawang.com) 版权所有