PHP Require conditional reference issues

Source: Internet
Author: User
On the internet to see such a message
The Include () function is the same as require (), but there are some differences in usage, include () is a conditional include function, and require () is an unconditional include function.
Regardless of the $something value, the following code will include the file somefile.php in the file:
if ($something) {require ' somefile.php ';}

But in my actual test, the conditions are not included when the condition is false.

Because the environment is different, or there is another reason, please advise us


Reply to discussion (solution)

What you see is an introduction to PHP4.
In php5, both require and include are loaded at precompiled time (invisible when not in use)
The difference between the two is limited to the former when an error breaks the program, and the latter does not

This is obviously wrong, at least in the current version, if (false) {} will not execute the IF code block at all.

$something = 0 or equal to null look, you're going to introduce it.

  • 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.