////////////////////////////////////////////////
//获取远程PHP代码进行本地执行
////////////////////////////////////////////////
//本地执行文件 local.php,代码如下
$url = "http://localhost/long-distance.php"; //这里是远程文件的网址路径,即使是在本地测试,也需要http://localhost
eval(get_url_content($url));
function get_url_content($url) {
if(function_exists('curl_init')) {
$ch = curl_init();
$timeout = 5;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
} else {
$file_contents = file_get_contents($url);
}
return $file_contents;
}
//-----------------------------------------------------
//远程文件 long-distance.php,任意PHP代码,不需要〈? ?〉符号,代码必须是标准的PHP代码
//如一个简单的输出
$ok="yes";
echo $ok;
//获取远程PHP代码进行本地执行
////////////////////////////////////////////////
//本地执行文件 local.php,代码如下
$url = "http://localhost/long-distance.php"; //这里是远程文件的网址路径,即使是在本地测试,也需要http://localhost
eval(get_url_content($url));
function get_url_content($url) {
if(function_exists('curl_init')) {
$ch = curl_init();
$timeout = 5;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
} else {
$file_contents = file_get_contents($url);
}
return $file_contents;
}
//-----------------------------------------------------
//远程文件 long-distance.php,任意PHP代码,不需要〈? ?〉符号,代码必须是标准的PHP代码
//如一个简单的输出
$ok="yes";
echo $ok;
文章来源:桂林唯创网络