Home> php教程> php手册> body text

PHP中include和require的区别,phpincluderequire

WBOY
Release: 2016-06-13 08:55:43
Original
1818 people have browsed it

PHP中include和require的区别,phpincluderequire

include和require的区别,其实两者没有太大的区别,如果要包含的文件不存在,include提示notice,然后继续执行下面的语句,require提示致命错误并且退出。

根据测试,win32平台下它们都是先包含后执行,所以被包含文件里最好不要再有include或require语句,这样会造成目录混乱。

或许*nux下情况不同,暂时还没测试。如果一个文件不想被包含多次可以使用include_once或require_once## 读取,写入文档数据:

 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 }
Copy after login



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!