SoFunction
Updated on 2025-04-08

PHP file introduction learning knowledge point 6. Reading and writing operation codes for PHP files


<?php
//Open the file
$fp=fopen('', 'r');
//Read file content You can use the following two functions to operate fread, file_get_contents
$str=fread($fp, filesize('')); //filesize is to get the file size
$content=file_get_contents('');
//Write a file
$news=fopen('', 'w');
fwrite($news, $content);
//Close the file stream
fclose($fp);
fclose($news);
echo $content;
?>