PHP tutorial - php read and output other file methods

PHP Tutorial - How to read and output other files in php

People often think of the phenomenon of slow access and white pages. If you are in the test environment, you can restart the php-fpm process of PHP and find that it is fine. In this issue, we have invited the PHP gurus from Brothers PHP Education www.lampbrother.net to share with you. PHP reads and outputs other file methods. Thank you for bringing us this pleasant experience. Friends, get ready Is this technology journey over?

ob_start();
iconv('utf-8','gb2312',readfile('1.html')); //Direct output text content
echo '<hr>';

$data = file_get_contents('./1.html ',null,null,0,10);
var_dump($data);//output string
echo '<hr>';


$data = file('./1.html');
var_dump($data);/ /output array
echo '<hr>';

$stream = fopen('./1.html','r');
echo stream_get_contents($stream,12);//output string
echo '<hr>';

//fread() reads a file (safe for binary files) filesystem pointer, typically a resource 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. I hope everyone has to help.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326642405&siteId=291194637