Reputation: 15889
For example:
Content of 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';
Content of server-b.com/test.php:
mail($foo, $bar, $qux); header('location: http://google.com');
Now running server-a.com/test.php
should output hello world one hello world two
. And it should not redirect to google.com even though server-b.com/test.php
was called successfully.
Upvotes: 0
Views: 7166
Reputation: 3726
You can use Symfony2's Process component for that. Example:
use Symfony\Component\Process\PhpProcess;
$process = new PhpProcess(<<<EOF
<?php echo 'Hello World'; ?>
EOF
);
$process->run();
Upvotes: 0
Reputation: 97672
You can remove the location header with header_remove
. After you include server-b.com/test.php just call
header_remove('Location');
Upvotes: 0
Reputation: 3950
You can use file_get_contents()
file_get_contents("server-b.com/test.php");
or Curl
$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);
Upvotes: 5
Reputation: 184
use this function file_get_contents():
file_get_contents("server-b.com/test.php");
Upvotes: 0