3v4l.org

run code in 300+ PHP versions simultaneously
<html> <head> <title>PHP Test</title> </head> <body> <?PHP $filename = 'text.txt'; $somecontent = "My name is Chukwudi and this is my contribution \n"; // Let's check if file exists and writable. IF (IS_WRITABLE($filename)) { // opening $filename. // that's where $somecontent will go when we fwrite() it. IF (!$handle = FOPEN($filename, 'a')) { PRINT "Cannot open file ($filename)"; EXIT; } // Write $somecontent to text.txt file. IF (!FWRITE($handle, $somecontent)) { PRINT "Cannot write to file ($filename)"; EXIT; } PRINT "Success, wrote ($somecontent) to file ($filename)"; FCLOSE($handle); } ELSE { PRINT "The file $filename is not writable"; } ?> </body> </html>

preferences:
50.85 ms | 402 KiB | 5 Q