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...

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"; 
?>

You should use Relative paths in PHP include function.

include '/path/to/file.php';  // You can include file by relative path

As per documentation,

include through HTTP

If "URL include wrappers" are enabled in PHP, you can specify the file to be included using a URL (via HTTP or other supported wrapper - see Supported Protocols and 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.

/* This example assumes that www.example.com is configured to parse .php
* files and not .txt files. Also, 'Works' here means that the variables
* $foo and $bar are available within the included file. */

// 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';

$foo = 1;
$bar = 2;
include 'file.txt';  // Works.
include 'file.php';  // Works.

Warning

Security warning

Remote file may be processed at the remote server (depending on the file extension and the fact if the remote server runs PHP or not) but it still has to produce a valid PHP script because it will be processed at the local server. If the file from the remote server should be processed there and outputted only, readfile() is much better function to use. Otherwise, special care should be taken to secure the remote script to produce a valid and desired code.

Here is understanding of Paths.

1) Relative Paths

index.html
/graphics/image.png
/help/articles/how-do-i-set-up-a-webpage.html

2) Absolute Paths

http://www.mysite1.com
http://www.mysite2.com/graphics/image.png
http://www.mysite3.com/help/articles/how-do-i-set-up-a-webpage.html

The first difference you'll notice between the two different types of links is that absolute paths always include the domain name of the website, including http://www., whereas relative links only point to a file or a file path. When a user clicks a relative link, the browser takes them to that location on the current site.

For that reason, you can only use relative links when linking to pages or files within your site, and you must use absolute links if you're linking to a location on another website.

For more information, Refer this link also.

Hope it will help you :)