Trownt Posted March 21, 2008 Share Posted March 21, 2008 I had a script working on my site that would connect to an SSL page, then grab contents of another page by switching the CURLOPT_URL and doing another exec. However I think my server was updated to a newer version of PHP, and it broke the script. The issue is, if I do multiple curl_exec() and have CURLOPT_RETURNTRANSFER = TRUE, then it keeps appending the old response on to the new one. $curl = curl_init(); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($curl, CURLOPT_TIMEOUT, 120); curl_setopt($curl, CURLOPT_TIMEOUT, 45); curl_setopt($curl, CURLOPT_HTTPPOST, TRUE); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_URL, "...../test1.txt"); $test1 = curl_exec($curl); echo "(".$test1.")<br />"; curl_setopt($curl, CURLOPT_URL, "...../test2.txt"); $test2 = curl_exec($curl); echo "(".$test2.")<br />"; curl_close($curl); GIVEN: test1.txt is a file that just has "test1," test2.txt is a file that just has "test2," this script outputs: (test1,) (test1,test2,) Is this normal? Is there anyway to clear the response? If I change CURLOPT_RETURNTRANSFER = FALSE, the the script outputs: test1,(1) test2,(1) which is what I would expect. Link to comment https://forums.phpfreaks.com/topic/97179-curlopt_returntransfer-appending/ Share on other sites More sharing options...
dingus Posted March 21, 2008 Share Posted March 21, 2008 i was having the same problem and to solve it i changed curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); to curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); Link to comment https://forums.phpfreaks.com/topic/97179-curlopt_returntransfer-appending/#findComment-497286 Share on other sites More sharing options...
Trownt Posted March 21, 2008 Author Share Posted March 21, 2008 Didn't work for me. Link to comment https://forums.phpfreaks.com/topic/97179-curlopt_returntransfer-appending/#findComment-497440 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.