This article mainly introduces the method of reading and outputting other files in PHP. Interested friends can refer to it. I hope it will be helpful to everyone.
is as follows:
ob_start(); iconv('utf-8','gb2312',readfile('1.html')); //直接输出文本内容 echo '<hr>'; $data = file_get_contents('./1.html',null,null,0,10); var_dump($data);//输出字符串 echo '<hr>'; $data = file('./1.html'); var_dump($data);//输出数组 echo '<hr>'; $stream = fopen('./1.html','r'); echo stream_get_contents($stream,12);//输出字符串 echo '<hr>'; //fread() 读取文件(可安全用于二进制文件) 文件系统指针,是典型地由 fopen() 创建的 resource(资源)。 $data = fopen('./1.html','rb'); $contents = fread($data,filesize('./1.html')); echo $contents;//输出字符串
Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations:
phpOne file to configure WeChat jssdk
php Detailed explanation of file splitting and merging to achieve breakpoint resume transfer
php Implement WeChat development to obtain user information
The above is the detailed content of PHP implements the method of reading and outputting other files. For more information, please follow other related articles on the PHP Chinese website!