Google News
logo
PHP - Interview Questions
Which function you can use in PHP to open a file for reading or writing or for both?
You can use fopen() function to read or write or for doing both in PHP.
 
Example :
$file1 = fopen("myfile1.txt","r"); //Open for reading
$file2 = fopen("myfile2.txt","w"); //Open for writing
$file3 = fopen("myfile3.txt","r+"); //Open for reading and writing
Advertisement