Difference Between include and require in PHP, phpincluderequire_PHP tutorial

Source: Internet
Author: User
Tags flock
The difference between include and require in PHP is phpincluderequire. The difference between include and require in PHP: the difference between phpincluderequireinclude and require is actually not much different. if the file to be included does not exist, the include prompt is notice, then, the difference between include and require in PHP is phpincluderequire.

The difference between include and require is actually not much different. if the file to be included does not exist, include prompts notice and continues to execute the following statement. require prompts a fatal error and exits.

According to the test, on the win32 Platform, they are all included first and then executed. Therefore, it is recommended that there be no include or require statements in the contained files, which will cause directory confusion.

Maybe * The situation is different in nux and has not been tested yet. If you do not want to include a file multiple times, you can use include_once or require_once # to read and write the file data:

 1 function r($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 function w($file_name,$data,$method="w"){ 9 $filenum=@fopen($file_name,$method);10 flock($filenum,LOCK_EX);11 $file_data=fwrite($filenum,$data);12 fclose($filenum);13 return $file_data;14 }



Except for the difference between include and require, there is not much difference between the two. if the file to be included does not exist, include prompts notice, and then...

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.