繁体   English   中英

从包含的文件中包含php

[英]include php from included file

我想在其他php文件中包含php文件,但是我不想在第一个文件中使用include或require函数,例如,我有“ to_include.php”和“ main.php”,那么按常规方式包含是:

在“ main.php”中:

include('to_include.php');

但是我不想这样做,例如我想要这样的事情:

在“ to_include.php”中:

include_this_file_to('main.php');

或任何其他可以帮助我做到这一点的方式。

注意:我也不想这样做:

在“ third_file.php”中:

include('to_include.php');
include('main.php');

我很确定没有办法去做你想做的事情。 这将需要PHP搜索整个文件系统,以查看是否还有另一个脚本包含相关的include_this_file_to()调用,这似乎不太实际。

我能想到的最好的方法是使用您的third_file.php ,然后让服务器将main.php重写为third_file.php

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM