老话题了,不得不再问一下include和require
手册上,include和require的区别只有一点,就是出错时产生的不同级别的错误。
但是,网上关于两者的区别远不止这一点,搞得我非常混乱
下面这些是我从网上摘抄的一些观点和疑问
--------------------------------------------------------------------------------------------------------
什么是“只要程序一执行就调用”?
<?php<br />//aa.php<br />echo 'aa';<br />require './bb.php';
我暂时这么想,因为也不懂什么编译之类的。请指点
require情况:执行aa.php时,把aa.php和bb.php一起编译,然后执行;
include情况:先把aa.php编译->执行,发现有include,然后把bb.php编译->执行bb.php,完成后返回继续执行aa.php下面的代码。
--------------------------------------------------------------------------------------------------------
这一点就非常搞不明白了。aa.php还是上面的那个代码,下面是bb.php,执行得好好的
<?php<br />//bb.php<br />if(true){<br /> echo 'bb';<br />}<br />return 'abc';
--------------------------------------------------------------------------------------------------------
文章中举了个例子并得出结论:
<?php<br />//aa.php<br />echo 'aa';<br />$i=1;<br />while($i<3){<br /> require './test' . $i . '.php';<br /> $i++;<br />}
但是,我测试却能将test1.php和test2.php都引入进来
<?php<br />echo 'test1';
<?php<br />echo 'test2';
输出:aatest1test2
--------------------------------------------------------------------------------------------------------------------------
<?php<br />//aa.php<br />if(false){<br /> require './bb.php';<br />}
是否是这样?如何能证明已经引入了bb.php?
------------------------------------------------------------------------------------------------------------------------
另外,还有一个关于报错的问题,手册上这么讲

<?php<br />//aa.php<br />include 'nofile.php';<br />//require 'nofile.php';
报错如下:
第一个warning是报什么样的错误?两个都是warning
第二个看像是在include_path里找不到而报的错?
------解决思路----------------------
所有的说明一最新的手册为准
网上关于include和require的描述,大多是基于php4的
到了php5时代,就只剩下 出错时产生的不同级别的错误 的区别了
------解决思路----------------------
IT知识的更新换代太快了,一切以官方手册为准,也可以研读一下PHP源码,看看是怎么处理的,那是最正确的。

The article discusses PHP, detailing its full form, main uses in web development, comparison with Python and Java, and its ease of learning for beginners.

PHP handles form data using $\_POST and $\_GET superglobals, with security ensured through validation, sanitization, and secure database interactions.

The article compares PHP and ASP.NET, focusing on their suitability for large-scale web applications, performance differences, and security features. Both are viable for large projects, but PHP is open-source and platform-independent, while ASP.NET,

PHP's case sensitivity varies: functions are insensitive, while variables and classes are sensitive. Best practices include consistent naming and using case-insensitive functions for comparisons.

The article discusses various methods for page redirection in PHP, focusing on the header() function and addressing common issues like "headers already sent" errors.

Article discusses type hinting in PHP, a feature for specifying expected data types in functions. Main issue is improving code quality and readability through type enforcement.

The article discusses PHP Data Objects (PDO), an extension for database access in PHP. It highlights PDO's role in enhancing security through prepared statements and its benefits over MySQLi, including database abstraction and better error handling.

Article discusses creating and securing PHP APIs, detailing steps from endpoint definition to performance optimization using frameworks like Laravel and best security practices.


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

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

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

Zend Studio 13.0.1
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Atom editor mac version download
The most popular open source editor
