The difference between include and require in PHP, phpincluderequire_php tutorial

Source: Internet
Author: User
Tags flock

The difference between include and require in PHP, Phpincluderequire


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:

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



http://www.bkjia.com/PHPjc/1048763.html www.bkjia.com true http://www.bkjia.com/PHPjc/1048763.html techarticle The difference between include and require in PHP, Phpincluderequire include and require, in fact, there is not much difference between the two, if you want to include the file does not exist, include prompt notice, and then ...

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