File Handling in PHP

 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

The Importance of Cybersecurity in the Digital Age

 The Importance of Cybersecurity in the Digital Age Introduction: In today's digital age, where technology is deeply intertwined with ev...