<?php //specify the filename and we call it as hello.txt $testfile = 'hello.txt'; //and inside the if statement, we pass the $testfile variable to fopen and we specify the mode as write //and fopen return a handle as a value, and using handle is useful because we could close it }else{ //if the file can't be open..and it can prevent some error might happen echo 'Could not open the file'; } ?>
<?php //specify the filename and we call it as hello.txt $testfile = 'hello.txt'; //and inside the if statement, we pass the $testfile variable to fopen and we specify the mode as write //and fopen return a handle as a value, and using handle is useful because we could close it $somestring = "\nnew append data 1\n"; $somestring = "new append data 2\n"; //close the handle }else{ //if the file can't be open..and it can prevent some error might happen echo 'Could not open the file'; } ?>