How to respond to the client in xml format in php?

please help how to respond to his request in xml format echo to get the response and read using SimpleXMLElement
August 23rd 19 at 10:48
1 answer
August 23rd 19 at 10:50
header('Content-Type: text/xml');
echo '<xml>....</xml>';


And how do you no echo (or similar) will derive a response to the request?
if I get a response through the query, it may work and my answer a query it will make using cURL to receive his code
$result = curl_exec($ch);
// close the session and release resources
curl_close($ch);


$xml = new SimpleXMLElement($result);

$result=$xml->RESULT;

if I answer via the echo he will not be able to work with my answer that's the problem - Buster.Wiega commented on August 23rd 19 at 10:53
: I'm sorry? He will also be schemitsya using curl. Why did you decide that the echo will not give any response to him? HaDarom before echo you say to the one who makes a request, that now the response will be XML. - Vivianne5 commented on August 23rd 19 at 10:56
server.php
header('Content-Type: text/xml');
$name=$_POST['name'];
$phone=$_POST['phone'];
//get the data record the response to the database sends the response in xml format

$queryup="INSERT INTO table(`name`,`phone`) VALUES ('$name', 'phone") ";...
now I have answer the query of type two options here such xml
if(mysql_query($query))
{
echo $result ='
<response>
<result>ok</result>
<result_id>1<result_id>
</result_id></result_id></response>
';
}
client.php
$name='Ivanov');
$phone='878787878787');

//initialize session
$ch = curl_init();
// set URL and other needed parameters
curl_setopt($ch, CURLOPT_URL, "http://сайт/server.php");
curl_setopt($ch, CURLOPT_POST, 1); //will POST
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, THIS, false);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'name='. $name.'&phone='. $phone.);
$result = curl_exec($ch);
// close the session and release resources
curl_close($ch);

$xml = new SimpleXMLElement($result);

echo $result=$xml->RESULT;

echo $result_id=$xml->RESULT_ID;
but the client does not withdraw the answer
and if you do echo $result; then withdraw, and the client should these two settings he recorded in the database - Buster.Wiega commented on August 23rd 19 at 10:59

Find more questions by tags PHPXML