php include 能包含远程文件吗
的有关信息介绍如下:可以,但是需要修改配置程序。具体如下:最好检查一下php.ini中的配置选项allow_url_include,如果为on则可以包含,否则不能包含; Whether to allow include/require to open URLs (like http:// or ftp://) as files.allow_url_include = Off做个简单的测试,此时allow_url_include的值为Off测试前配置一下hosts文件,这样可以在一台电脑上面进行模拟测试192.168.1.101 www.test1.com192.168.1.102 www.test2.compath.php文件内容为:\n";include("http://www.test2.com/research/path/path.php");?>path1.php文件内容为:执行http://www.test1.com/research/path/path.php,输出如下This is file path.phpWarning: include() [function.include]: URL file-access is disabled in the server configuration in E:\myphp\research\path\path.php on line 3Warning: include(http://www.test2.com/research/path/path.php) [function.include]: failed to open stream: no suitable wrapper could be found in E:\myphp\research\path\path.php on line 3Warning: include() [function.include]: Failed opening 'http://www.test2.com/research/path/path.php' for inclusion (include_path='.;C:\php5\pear') in E:\myphp\research\path\path.php on line 3将php.ini中的allow_url_include改为On,重新启动web服务器,再次执行http://www.test1.com/research/path/path.php,输出如下:This is file path.phpThis is file path1.php in root directory 将allow_url_include设为On以后,就可以包含远程文件了,并且包含的是远程文件执行的结果。