I have a PHP script, say a.php, which is called from JS using Ajax (this is a POST request and some data is passed to the script).
I have another PHP script, say b.php, from which I would like to call a.php and pass it some data. I expect a.php to do the job just like if it was called from JS.
I don't want to do include('a.php'); because of possible collision between variable names.
How could I do this ?
Why aren't you just putting these together as functions, using an include, and calling them like you would in C++ or something? Global is bad.
One solution (if imperfect) is to use file_get_contents() with a URL.
So, something like:
$data = file_get_contents('http://domain.com/a.php?this=that&that=this');
$json = json_decode($data);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With