Why is the generated txt file empty? The following code does not have any conditions before, but generates an empty file if (! File_exists("shang_ci_zong_shu_1.txt & quot;) {// (value generated for the first time) if the total number of files does not exist, the generated txt file. $ handle = fope why is the generated txt file empty?
The following code does not have any conditions before, but an empty file is generated.
If (! File_exists ("shang_ci_zong_shu_1.txt") {// (value generated for the first time) if the total number of files does not exist, a txt file is generated.
Export handleappsfopen('shang_ci_zong_shu_1.txt ', "w ");
Echo "aa"; // The output is successfully tested, but an empty file is generated.
Fwrite ($ handle, "1"); // generate default value 1
Fclose ($ handle );
}
There is no problem in the if statement test below ..
Export handleappsfopen('shang_ci_zong_shu_1.txt ', "w ");
Fwrite ($ handle, "1"); // generate default value 1
Fclose ($ handle );
------ Solution --------------------
You can determine the return value of fwrite to see what it is.
------ Solution --------------------
You cannot understand. Your file exists. Naturally, it will not enter the if branch.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service