File_put_contents zero

221 Views Asked by At

i want to use this code : echo file_put_contents('any.txt', 0); result will be 0! I know that i can put zero in quotation but what about $_GET ? Like this : echo file_put_contents('any.txt', $_GET['GetZero']); Result can't be 1 while we send 0 with GetZero parameter

maybe 0 can not be send with any way :|

How can do that?

1

There are 1 best solutions below

0
Titus On

the function file_put_contents returns the number of bytes that were written to the file, or false on failure.

so if you will check your file is written use this:

$write = file_put_contents('any.txt', $_GET['GetZero']);
if($write!==false){
 echo "success";
}else{
 echo "fail";
}