Home > Backend Development > PHP Tutorial > PHP instance tutorial PHP tutorial-php method of reading and outputting other files

PHP instance tutorial PHP tutorial-php method of reading and outputting other files

WBOY
Release: 2016-07-27 16:56:22
Original
1325 people have browsed it

PHP Tutorial - How to read and output other files in php
People often think of some issues about slow access and white pages. If it is a test environment, you can restart the php-fpm process of PHP and find that it is fine again, but it will appear again after a while. For similar questions, in this issue we have invited PHP experts from Brothers PHP Education www.lampbrother.net to share with you the method of reading and outputting other files in PHP. Thank you Tie Cheng for bringing us this enjoyable experience. Friends, get ready. Are you ready for this technical journey?
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 a resource typically created by fopen().
$data = fopen('./1.html','rb');
$contents = fread($data,filesize('./1.html'));
echo $contents;//output string
Summarized PHP tutorial on how to read and output other files in PHP. I hope everyone has to help.

The above introduces the PHP example tutorial PHP tutorial-php method of reading and outputting other files, including the content of the PHP example tutorial. 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