简体   繁体   English

是否可以从文本文件加载php函数?

[英]Is is possible to load php functions from a text file?

I recently updated my server to use SuPHP to increase security. 我最近更新了服务器,以使用SuPHP来提高安全性。

One downside is that I used to be able to include files from my other domains hosted on my server using absolute paths to the file. 一个缺点是,我以前能够使用文件的绝对路径来包含服务器上托管的其他域中的文件。 This doesn't work anymore. 这不再起作用了。

The file in particular that I include from other domains is my functions file which is huge and used on all my websites. 我特别从其他域包含的文件是我的功能文件,该文件很大,并且在我的所有网站上都使用过。 For the sake of maintainability, I've been including a central file rather than uploading the file to each server every time I make changes. 为了可维护性,我一直包含一个中央文件,而不是每次进行更改时都将文件上传到每个服务器。

I thought that saving the functions file as plain text and using file_get_contents() across domains might be the right way to go. 我认为将功能文件另存为纯文本并跨域使用file_get_contents()可能是正确的方法。 But apparently this doesn't work. 但是显然这是行不通的。

Is there a way to make it work? 有办法使它起作用吗?

Or is there some other whizz bang function that can help me achieve my goal? 还是还有其他一些功能可以帮助我实现目标?

Cheers. 干杯。

It sounds like you need configure open_base_dir in each of your websites vhosts so they are allowed to access the directory where these function files reside. 听起来您需要在每个网站虚拟主机中配置open_base_dir,以便允许它们访问这些功能文件所在的目录。 You should put them in a common location. 您应该将它们放在一个公共位置。

open_basedir open_basedir

Another alternative would be to use php_info() to check your include path to see if there is a suitable location already configured where you could place these files, then simply include using include() 另一种选择是使用php_info()检查您的包含路径,以查看是否已经配置了可以放置这些文件的合适位置,然后只需使用include()

include_path include_path

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

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