You could connect to the file using CURL
, and specify a parameter.
The file could check that parameter and call a particular function.
It's not exactly what you want, but it should work. It's better to make this like an API, instead of including external PHP files and then calling the functions from them. You could add more security this way, like accepting connections only from certain URLs.
short.php
will contain something like
<?php
function writeMsg() {
echo "Hello world!";
}
writeMsg();
?>
The file from the other server can contain
<?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
will be the output of the short.php
script