dosf40815 2016-02-23 09:27 采纳率: 100%
浏览 54

PHP URL包含不起作用

I have a problem with an URL-include, which I don't understand...: For testing I have coded the following script:

<?php
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 1);
echo "First text";
include("http://www.xxxxxxxxxx.de/includetest.php");
echo "Second text"; 
?>

Allow_url_include is set to on. (via php.ini)

Allor_url_fopen ist set to on. (via php.ini)

The includetest.php only contains plain text for testing. There is no php-code.

The result of that script is only the "first text". After that the script is stopped.

If I use "or die('not working');" after the include, the result is the whole text (also the second text) with the following warning:

Warning: include(1): failed to open stream: No such file or directory in /srv2/www/htdocs/xhtml-test/_baustelle/testphp02.php on line 6 Warning: include(): Failed opening '1' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /srv2/www/htdocs/xhtml-test/_baustelle/testphp02.php on line 6

Why is that? I am at a loss...

  • 写回答

2条回答 默认 最新

  • douqiao4450 2016-02-23 10:24
    关注

    Here is the problem of code:

    // Won't work; file.txt wasn't handled by www.example.com as PHP
    include 'http://www.example.com/file.txt?foo=1&bar=2';
    
    // Won't work; looks for a file named 'file.php?foo=1&bar=2' on the
    // local filesystem.
    include 'file.php?foo=1&bar=2';
    
    // Works.
    include 'http://www.example.com/file.php?foo=1&bar=2';
    

    Ref. of this Is Here

    The file you are including is not a valid php file as it is already surved by a server as php.

    This code should work as you want:

    <?php
    error_reporting(E_ALL|E_STRICT);
    ini_set('display_errors', 1);
    echo "First text";
    echo file_get_contents("http://www.xxxxxxxxxx.de/includetest.php");
    echo "Second text"; 
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题