0

例えば:

server-a.com/test.phpのコンテンツ:

echo 'hello world one';

// now I need to call server-b.com/test.php here silently
// without interfering with user experience

echo 'hello world two';

server-b.com/test.phpのコンテンツ:

mail($foo, $bar, $qux); header('location: http://google.com');


現在実行中server-a.com/test.phpはが出力されますhello world one hello world twoserver-b.com/test.phpまた、正常に呼び出されたとしても、google.comにリダイレクトされるべきではありません。

4

4 に答える 4

5

file_get_contents()を使用できます

file_get_contents("server-b.com/test.php");

またはカール

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, "server-b.com/test.php"); 
curl_setopt($ch, CURLOPT_HEADER, TRUE); 
curl_setopt($ch, CURLOPT_NOBODY, TRUE); // remove body 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
curl_exec($ch); 
于 2012-10-24T22:18:50.037 に答える
0

この関数file_get_contents()を使用します。

file_get_contents("server-b.com/test.php");
于 2012-10-24T22:17:22.033 に答える
0

そのためにSymfony2のプロセスコンポーネントを使用できます。例:

use Symfony\Component\Process\PhpProcess;

$process = new PhpProcess(<<<EOF
    <?php echo 'Hello World'; ?>
EOF
);
$process->run();
于 2012-10-24T22:19:50.093 に答える
0

でロケーションヘッダーを削除できますheader_remove。server-b.com/test.phpを含めたら、

header_remove('Location');
于 2012-10-24T22:22:17.850 に答える