3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<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>
Output for 4.3.0 - 7.2.0
<html> <head> <title>PHP Test</title> </head> <body> The file text.txt is not writable </body> </html>