Table of Contents
PHP中include和require的区别,phpincluderequire
include
PHP中include和require的区别,phpincluderequire
include和require的区别,其实两者没有太大的区别,如果要包含的文件不存在,include提示notice,然后继续执行下面的语句,require提示致命错误并且退出。
根据测试,win32平台下它们都是先包含后执行,所以被包含文件里最好不要再有include或require语句,这样会造成目录混乱。
或许*nux下情况不同,暂时还没测试。如果一个文件不想被包含多次可以使用include_once或require_once## 读取,写入文档数据:
<span> 1</span> <span>function</span> r(<span>$file_name</span><span>) { </span><span> 2</span> <span>$filenum</span>=@<span>fopen</span>(<span>$file_name</span>,"r"<span>); </span><span> 3</span> @<span>flock</span>(<span>$filenum</span>,<span>LOCK_SH); </span><span> 4</span> <span>$file_data</span>=@<span>fread</span>(<span>$filenum</span>,<span>filesize</span>(<span>$file_name</span><span>)); </span><span> 5</span> @<span>fclose</span>(<span>$filenum</span><span>); </span><span> 6</span> <span>return</span> <span>$file_data</span><span>; </span><span> 7</span> <span>} </span><span> 8</span> <span>function</span> w(<span>$file_name</span>,<span>$data</span>,<span>$method</span>="w"<span>){ </span><span> 9</span> <span>$filenum</span>=@<span>fopen</span>(<span>$file_name</span>,<span>$method</span><span>); </span><span>10</span> <span>flock</span>(<span>$filenum</span>,<span>LOCK_EX); </span><span>11</span> <span>$file_data</span>=<span>fwrite</span>(<span>$filenum</span>,<span>$data</span><span>); </span><span>12</span> <span>fclose</span>(<span>$filenum</span><span>); </span><span>13</span> <span>return</span> <span>$file_data</span><span>; </span><span>14</span> }
Copy after login
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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
How to fix KB5055523 fails to install in Windows 11?
3 weeks ago
By DDD
How to fix KB5055518 fails to install in Windows 10?
3 weeks ago
By DDD
Roblox: Dead Rails - How To Tame Wolves
4 weeks ago
By DDD
Strength Levels for Every Enemy & Monster in R.E.P.O.
4 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Roblox: Grow A Garden - Complete Mutation Guide
2 weeks ago
By DDD

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics
Java Tutorial
1659
14


CakePHP Tutorial
1415
52


Laravel Tutorial
1309
25


PHP Tutorial
1257
29


C# Tutorial
1231
24

