Fastest Web Hosting

how to create a text file in php write content into that file.

0 votes
asked Oct 17, 2016 in PHP by Nitin Sangal (340 points)

1 Answer

0 votes
answered Oct 17, 2016 by vibhu.jain (580 points)
// File path
$filename = "/home/user/guest/newfile.txt";

// open file
$file = fopen( $filename, "w" );

if( $file == false ) {
echo ( "Error in opening new file" ); exit();
}

// Write into file 
fwrite( $file, "This is a simple test\n" );

// close file
fclose( $file );

Job Board

TechnicalSharp is a technical community of developers where they are sharing their knowledge and solutions and against it they are getting the score point which help them to make profile strong which is under eyes on MNC's
...