calling php script within php with return value
In the script to be called, make sure "<?php" start from the first line, first character. And, remove the "?>" away.
<?php//this is 'to-be-called.php'include("config.php");echo "complete";
Now call it this way:
<?php//this is 'caller.php'//should it come with full url?$Url = "http://localhost/path/to-be-called.php"; $Handle = curl_init($Url);$Response = curl_exec($Handle);curl_close($Handle);echo $Response;
Or take Jeroen's answer, it's the best way for calling on the same server! If you need to pass in parameters in POST/GET, tell 'caller.php' to save these values in global variables, then tell 'to-be-called.php' to get from these global ones.