4

我的服务器上有两个文件。文件a.php

<?php 
die('this is my text');
?>

文件 b.php:

<?php
file_get_contents('http://mysite.pl/a.php');
?>

但它不起作用......我不能使用file_get_contents,当文件位于同一台服务器上时,我不知道为什么。PHP信息:

allow_url_fopen: ON
allow_url_include: OFF

当我尝试在困难的服务器上使用文件 b.php 中的代码时 - 它工作... ;/

4

2 回答 2

0

您可以尝试使用 127.0.0.1,但它不适用于 VirtualHost。

于 2015-04-14T13:45:08.780 回答
-4

你可以试试相对路径。

如果a.phpb.php位于同一目录中,请执行以下操作:

// b.php (If a.php is in the same directory)
file_get_contents('./a.php');

如果a.php在上层目录中:

// b.php (If a.php is in an upper directory)
file_get_contents('../a.php');

如果a.php在根目录中:

// b.php (If a.php is in the root directory)
file_get_contents('/a.php');
于 2014-03-14T04:35:43.357 回答