是否可以停止包含php文件? [英] Is it possible to stop including a php file?

查看:109
本文介绍了是否可以停止包含php文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以停止在文件中间包含文件?

Is it possible to stop the inclusion of a file in the middle of a file?

例如,一个文件将包含:

For example, one file would contain:

include('home.php');

home.php ,它会尝试在某个时候取消包含:

and in home.php, it would try to cancel the inclusion at some point:

break; // I tried it doesn't work
echo "this will not be output

I我不是在谈论退出,这会阻止所有内容,甚至是根文件。我只想退出当前文件。

I'm not talking about an exit, which stops everything, even the root file. I just want the current file to be exited from.

推荐答案

取代 break ,使用 return


返回



如果从全局范围调用,则结束当前脚本文件的执行。如果当前脚本文件为 include() ed或 require() ed,然后将控制权传递回调用文件。

return

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.

这篇关于是否可以停止包含php文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆