包括来自url的php文件与php [关闭]

**i need use this file php Variables post server on url **

http://example.com/addData.php   (the other server)
-------------------------------------
$a_player1 = $_POST['a_player1'] = 1;            
$a_player2 = $_POST['a_player2'] = 3;

 htto://srore.com/getdata.php
 -------------------------------------
include("http://example.com/addData.php");
echo $a_player1;
echo $a_player2;

error ???

Notice: Undefined variable: a_player1
Notice: Undefined variable: a_player2

php.ini settings then allow_url_include On

You're including via an absolute URL (which is a hideously bad security problem), which means you're EXECUTING that "remote" php script, and loading its OUTPUT, not the php code it contains.

And if allow_url_fopen is disabled, then nothing gets loaded anyways, and no php code will be seen, because that url is never hit.

If that file is on the same server/site as your main one, then do NOT use a url, a simple include('addData.php') will do.

What you are looking for is something like a REST API. Something like: Creating a REST API using PHP