for writing i using below code this is very nice and simple work great now i have problem with this we already know that in window 260 character allow for file name problem start from here in code there is option if file not write stop and terminate process (or die("can't open file");) now i want simple if some reason file not write show echo not write and process continue.I try it myslef but it gives me error
my write function
function write($post, $myFile){
$fh = fopen($myFile, 'a+') or die("can't open file");
fwrite($fh, $post);
fclose($fh);
}
If there's a limit on the length of something then you could always check the length of the thing beforehand, and if you don't want your code to exit, then don't use die()
.
function write($post,$myFile){
if( strlen($myfile) > 260 ) {
echo "Filename too long";
return false;
} else {
if( ! $fh = fopen($myFile, 'a+') ) {
echo "can't open file";
return false;
}
fwrite($fh, $post);
fclose($fh);
return true;
}
}