Home > Backend Development > PHP Tutorial > Read file php method to read and output other files

Read file php method to read and output other files

WBOY
Release: 2016-07-28 08:25:31
Original
997 people have browsed it

ob_start();
iconv('utf-8','gb2312',readfile('1.html')); //Directly output the text content
echo '


';

$data = file_get_contents( './1.html',null,null,0,10);
var_dump($data);//Output string
echo '


';


$data = file('./1 .html');
var_dump($data);//Output array
echo '


';

$stream = fopen('./1.html','r');
echo stream_get_contents($ stream,12);//Output string
echo '


';

//fread() reads the file (safe for binary files) The file system pointer is typically created by fopen() resource.
$data = fopen('./1.html','rb');
$contents = fread($data,filesize('./1.html'));
echo $contents;//output string

The above introduces the method of reading files and php reading and outputting other files, including the content of reading files. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template