The difference between include and require in PHP

Source: Internet
Author: User
Tags flock
The difference between include and require, in fact, there is not much difference between the two, if the file to be included does not exist, include prompt notice, and then continue to execute the following statement, require prompt fatal error and exit.

According to the test, they are all included after the Win32 platform, so the included file is best not to have include or require statements, which will cause the directory confusion.

Perhaps *nux under different circumstances, not yet tested. If a file does not want to be included multiple times can be read using include_once or require_once##, write the document data:

1functionR$file _name) {2$filenum=@fopen($file _name, "R");3@Flock($filenum,lock_sh);4$file _data=@fread($filenum,filesize($file _name));5@fclose($filenum);6return$file _data;7}8functionW$file _name,$data,$method= "W"){9$filenum=@fopen($file _name,$method);TenFlock($filenum,lock_ex); One$file _data=fwrite($filenum,$data); Afclose($filenum); -return$file _data; -}


The above introduces the differences between include and require in PHP, including the contents of the content, I hope that the PHP tutorial interested in a friend helpful.

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