File and Directory Handling
File and Directory Handling
INTRODUCTION
PHP has some powerful file handling functions to manage files in a sever. Some of these functions requires some special settings at php.ini and some are available by default. We can open a file, write read and manage it by different functions.
<? // Store some text to enter inside the file $body_content="This is my content"; // file name $file_name="test_file.txt"; // Open the file in write mode, if file does not exist then it will be created. $fp = fopen ($file_name, "w"); // entering data to the file fwrite ($fp,$body_content); // closing the file pointer fclose ($fp); // changing the file permission. chmod($file_name,0777); ?>
THE END