File Handling in PHP
PHP can be used to read, write, and manipulate files on the server. File handling functions are used to open, read, write, and close files.
Example:
php
// write to a file
$file = fopen("example.txt", "w");
$txt = "Hello World";
fwrite($file, $txt);
fclose($file);
// read from a file
$file = fopen("example.txt", "r");
echo fread($file, filesize("example.txt"));
fclose($file);
No comments:
Post a Comment