2016-07-28 50 views
-3

**我需要使用這個文件的PHP變量的URL發佈服務器**從URL INCLUDIN php文件用PHP

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; 

錯誤???

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

php.ini設置然後allow_url_include在

+1

如果這兩個文件都在同一個文件夾中,則不需要使用「」http://...../test/「,只需使用include(」addData.php「); – jophab

回答

1

你包括通過一個絕對URL(這是一種可怕糟糕的安全問題),這意味着您執行的是「遠程」 PHP腳本,並加載它的OUTPUT,而不是它包含的php代碼。

如果allow_url_fopen被禁用,那麼反正沒有任何東西被加載,並且不會顯示任何PHP代碼,因爲該URL從未被擊中。

如果該文件與您的主服務器在同一個服務器/站點上,那麼請使用而不是使用一個url,簡單的include('addData.php')就可以。

+0

謝謝你的誤解 http://example.com/addData.php(其他服務器)--------------------------------- ------------------ htto://srore.com/getdata.php ------------------- ------------------ include(「http://example.com/addData.php」); echo $ a_player1; echo $ a_player2; * * error ??? ** 注意:未定義變量:a_player1 注意:U ndefined變量:a_player2 – aofdev