I am trying to create quite a basic API. The idea is quite simple - the client (using client.php) can send commands to the server (server.php) and then the appropiate data is returned. To begin with I have written a bunch of code which basically verifies an API key and password. Now onto my actual problem... function function post_request($action, $params) { $context = array('http' => array('method' => 'POST', 'content' => http_build_query($post_params)) ); $context_id = stream_context_create($context); $sock = fopen($this->server_addr, 'r', false, $context_id); if ($sock) { $result = ''; while (!feof($sock)) $result.=fgets($sock, 4096); fclose($sock); } else { die("Couldnt open"); } } function call($action, $params) { $xml = $this->post_request($action, $params); $sxml = @simplexml_load_string($xml); $result = self::convert_simplexml_to_array($sxml); } $result = call("test", array('api_key' => $this->api_key, 'api_pass' => $this->api_pass)); print_r($result); PHP: The above bit of code is cut down from what I have to save space plus I don't want to go handing out all my code. Basically the post_request() function uses fopen() to send the request to the server.php file. In my server.php I will eventually have code which will actually read the POST variables and act accordingly. However for now just for testing my server.php file contains this (and only this!). By running client.php everything works fine and the print_r() shows the values/data within that response from server.php However... If within server.php I use any PHP, even if I just echo the output the client.php receives nothing and therefore the print_r() doesnt display anything. By this I mean that the following wont work... So it works fine if the response text is just displayed like normal... but if it is echoed out or displayed any other way with PHP it isn't working.... Any ideas? Thanks
One more thing... After removing the @ before the simplexml_load_string() in the call function I get the following error. Line 65 of server.php is the final line which is '?>'