php - 跳过 PHP 中其余(包含的)文件

标签 php include

我包括文件 inner.phpouter.php , 我在 inner.php 中有一个条件我想停止执行inner.php但不是整个脚本,即我想跳到 outer.php 的第一行列入inner.php后,并且我不想将所有代码包装在 inner.php 中在 if 语句中。

有没有其他方法可以做到这一点?

最佳答案

只要做return;return($value);inner.php 文件的顶层。

If called from the global scope, then execution of the current script file is ended. If the current script file was include()ed or require()ed, then control is passed back to the calling file. Furthermore, if the current script file was include()ed, then the value given to return() will be returned as the value of the include() call.

关于php - 跳过 PHP 中其余(包含的)文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6136254/

相关文章:

php - 在PHP中多次包含同一个文件

C 中包含 ljpeg 库时出现编译错误

c++ - 作为初学者了解 C++ 中的预处理器指令

javascript - 用 Jade 插入包含指令?

c++ - '/'在一些头文件中的应用

javascript - 单击“确定”后显示警报消息并重定向

php - PDO::fetchAll 与 PDO::fetch 循环

php - 是否有等效于 php 的 urldecode 或 html_entity_decode() 的 javascript?

php - 将 PHP 数组保存到 MySQL?

php - 如何使用数据库 : Seeding? (laravel 5.3) 将数据从一个表导入到另一个表?