你可以连接到使用CURL
文件,并指定一个参数。
该文件可以检查该参数并调用特定功能。
这不完全是你想要的,但它应该工作。最好将它制作成API,而不是包含外部PHP文件,然后从它们调用函数。您可以通过这种方式添加更多安全性,例如只接受来自某些URL的连接。
short.php
将包含类似
<?php
function writeMsg() {
echo "Hello world!";
}
writeMsg();
?>
来自其他服务器的文件可以包含
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://daplonline.in/short.php");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
$result
将是short.php
脚本
的输出有你在处理有任何错误这个脚本? – DeDevelopers 2014-09-26 11:01:45
Impossible: http://stackoverflow.com/questions/3101327/using-includes-cross-domain-that-contain-php-code-failing – 2014-09-26 11:02:23
这是不可能的没有...即使这个网站是在相同的生产服务器ü会得到一个base_restriction对此包括 – DarkBee 2014-09-26 11:02:27