Why the generated TXT file is empty

Source: Internet
Author: User
Why is the generated txt file empty?
There is no conditional judgment in front of the preceding code, but an empty file is generated

if (!file_exists ("Shang_ci_zong_shu_1.txt")) {//(first build value) if the total number of files does not exist, a TXT file is generated.
$handle =fopen (' Shang_ci_zong_shu_1.txt ', ' W ');
echo "AA"; Test successful output here, but generate empty file
Fwrite ($handle, "1"); Generate default value 1
Fclose ($handle);
}

There is no problem with the IF statement test below:
$handle =fopen (' Shang_ci_zong_shu_1.txt ', ' W ');
Fwrite ($handle, "1"); Generate default value 1
Fclose ($handle);

------Solution--------------------
Consider the return value of fwrite to see what it is.
------Solution--------------------
I can't read it. There's a file for you. Nature will not enter the IF branch.
  • Contact Us

    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

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.