May 13, 2015
0
Level 1
Curl problem with string and variable?
Guys, I 'v need Curl to post xml to provider's server.
Would you please tell me what is the difference between those codes.
- Works fine.
$xml='xml= ';US
$ch = curl_init();
$header=[ "Content-type: application/x-www-form-urlencoded","charset=utf-8"];
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_exec($ch);
2.Fail.
make a txt file contain the characters 'xml= '.US
$xml=file_get_contents("country.txt");
$ch = curl_init();
$header=[ "Content-type: application/x-www-form-urlencoded","charset=utf-8"];
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_exec($ch);
So. what's the difference between $xml one set as charectors and another by file_get_contents?Thank you.
Please or to participate in this conversation.