PHP File Open/Write

This section will provide details about php write functions.

Writing data to file

This example will demonstrate how to write data into a file.

	//Write a File
	$fh=fopen("file.txt",'w') or die("file not found"); //First Step Open a file with Write Mode
	$text="Line 1 \r\nLine 2 \r\nLine 3 \r\nLine 4"; //Prepare the data for file
	fwrite($fh,$text) or die('Unable to write to File');//Write the file by $fh object and string
	fclose($fh); //Close the File Object