包含/要求HTTP地址 [英] Include/Require HTTP Address

查看:143
本文介绍了包含/要求HTTP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要包含一个我只能通过完整的HTTP地址访问的PHP文件。我对这个话题很困惑,我听说这是一个不好的做法。我怎么解决这个问题?

I'm in need to include a PHP file that I can only reach with a complete HTTP address. I'm confused about this topic, I've heard it's a bad practice. How can I solve that?

推荐答案

来自手册: http://php.net/manual/en/function.include.php

还阅读 附加的安全警告

also read Security warning that attached

如果 URL fopen wrappers 在PHP中启用(它们是默认配置),你可以使用URL指定要包含的文件(通过HTTP或其他受支持的包装器 - 请参阅协议列表中支持的协议/包装列表)而不是本地路径名。如果目标服务器将目标文件解释为PHP代码,则可以使用与HTTP GET一起使用的URL请求字符串将变量传递给包含的文件。严格来说,这与包含文件并使其继承父文件的变量范围完全相同;该脚本实际上正在远程服务器上运行,然后结果将包含在本地脚本中。

If "URL fopen wrappers" are enabled in PHP (which they are in the default configuration), you can specify the file to be included using a URL (via HTTP or other supported wrapper - see List of Supported Protocols/Wrappers for a list of protocols) instead of a local pathname. If the target server interprets the target file as PHP code, variables may be passed to the included file using a URL request string as used with HTTP GET. This is not strictly speaking the same thing as including the file and having it inherit the parent file's variable scope; the script is actually being run on the remote server and the result is then being included into the local script.

这篇关于包含/要求HTTP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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