简体   繁体   English

从包含的文件中包含php

[英]include php from included file

i want to include php file in other php file but i dont want to use include or require function in first file, for example i have 'to_include.php' and 'main.php' then include in normal way is: 我想在其他php文件中包含php文件,但是我不想在第一个文件中使用include或require函数,例如,我有“ to_include.php”和“ main.php”,那么按常规方式包含是:

in 'main.php': 在“ main.php”中:

include('to_include.php');

but i dont want to do this, for example i want some thing like this: 但是我不想这样做,例如我想要这样的事情:

in 'to_include.php': 在“ to_include.php”中:

include_this_file_to('main.php');

or any other way that can help me to do this. 或任何其他可以帮助我做到这一点的方式。

Note: i dont want to do this too: 注意:我也不想这样做:

in 'third_file.php': 在“ third_file.php”中:

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

I'm pretty sure there's no way to do what you're trying to do. 我很确定没有办法去做你想做的事情。 It would require PHP to search the entire filesystem to see if there's another script that contains a relevant include_this_file_to() call, which hardly seems practical. 这将需要PHP搜索整个文件系统,以查看是否还有另一个脚本包含相关的include_this_file_to()调用,这似乎不太实际。

The best I can think of is to use your third_file.php , and then have the server rewrite main.php to third_file.php . 我能想到的最好的方法是使用您的third_file.php ,然后让服务器将main.php重写为third_file.php

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

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