Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100 off


PHP Tutorials and Scripts   




Title: Interserver Communications    Marked Cool    (Review this resource)
Author: davidlo
Posted On: 2004-12-20
Category: Home > PHP Tutorials

Popularity: 1 points out of 10    

Description: How to let two separated HTTP and PHP systems communicate with each other without using sockets.

Total Hits: 1436     Total Votes: 0     Total Points: 0 (1 reviews)    

Page Navigation:  [1]  [2]  [3]


Interserver Communications




Part I

For some applications, you may need two independent HTTP servers to exchange information with each other. Given the runtime and possible Safe Mode restrictions imposed on the PHP setup, using sockets is not a viable solution. However, you can simply just have the two servers communicate by having them retrieve the results of a PHP script. Let us start with an example:

requester.php:
<?php 
$str=file_get_contents("http://server/client.php"); 
echo "Server returned $str";
?>
client.php:
<?php 
echo "OK"; ?>

Provided the files are in the correct places, running requester.php should output

Server returned OK

Now that we have the basics down, let's move on to basic authentication, as most of the time we don't want outsiders just typing in client.php in their web browser to gain access to it.

Page Navigation:  [1]  [2]  [3]



© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.