Home  >  Article  >  Backend Development  >  PHP的 include是否可以包含外网远程的一个config.php呢?并且获取config里面常量

PHP的 include是否可以包含外网远程的一个config.php呢?并且获取config里面常量

WBOY
WBOYOriginal
2016-07-06 13:53:281037browse

PHP的 include是否可以包含外网远程的一个config.php呢?并且获取config里面常量

回复内容:

PHP的 include是否可以包含外网远程的一个config.php呢?并且获取config里面常量

要是真可以直接这么干的话,那网络就真不安全了。

include可以包含远程,但是那个远程config.php文件的代码肯定是没办法拿到的,因为会被解析掉,你能拿到只是解析后输出的内容。那你倒不如直接curl拉取远程的json文件,然后解析得到值呢。

可以
用 readfile() 更好
http://php.net/manual/zh/function.include.php

好危险的想法 用api的思路吧

你这是怕别人黑你不够方便吗?太危险了。用API或者RPC之类的方案吧。

要看远程服务器能不能解析PHP,如果不能,那么远程服务器就会访问该文件的原始内容,如果能,返回的就是解析后的html内容。

包含远程文件很不安全 建议用API

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn