我的服务器上有两个文件。文件a.php:
<?php
die('this is my text');
?>
Run Code Online (Sandbox Code Playgroud)
文件b.php:
<?php
file_get_contents('http://mysite.pl/a.php');
?>
Run Code Online (Sandbox Code Playgroud)
但它不起作用...我无法使用file_get_contents,当文件位于同一服务器上时,我不知道为什么。PHP 信息:
allow_url_fopen: ON
allow_url_include: OFF
Run Code Online (Sandbox Code Playgroud)
当我尝试在困难的服务器上使用文件 b.php 中的代码时 - 它工作......;/
flu*_*lux -4
你可以试试相对路径。
如果a.php和b.php位于同一目录中,请执行以下操作:
// b.php (If a.php is in the same directory)
file_get_contents('./a.php');
Run Code Online (Sandbox Code Playgroud)
如果a.php是在上层目录:
// b.php (If a.php is in an upper directory)
file_get_contents('../a.php');
Run Code Online (Sandbox Code Playgroud)
如果a.php在根目录下:
// b.php (If a.php is in the root directory)
file_get_contents('/a.php');
Run Code Online (Sandbox Code Playgroud)