// if not file is there then automatic create and write inside it. $fptr = fopen('myfile.txt','w'); fwrite($fptr,"i am writing file in this "); fwrite($fptr,'writing another line.'); fclose($fptr);