How to remove extra symbols from CURL in PHP? -
i have simple curl request socket, returns process pid. problem there chars/symbols witch unseen. code is:
for ($i = 0; $i < 3; $i++ ) { $ch = curl_init($server); curl_setopt($ch, curlopt_ssl_verifyhost, 0); curl_setopt($ch, curlopt_ssl_verifypeer, 0); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, '<ping></ping>'); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_connecttimeout ,0); curl_setopt($ch, curlopt_timeout, 400); $output = array( 'result' => curl_exec($ch), 'info' => curl_getinfo($ch), 'error' => curl_error($ch) ); curl_close($ch); var_dump($output['result']); var_dump(trim($output['result'])); var_dump($pid); echo "----------------\n"; if (trim($output['result']) == $pid) die('true'); sleep(2); } die('false');
output looks like:
bool(false)
string(0) ""
string(5)
"14262"
----------------
string(7) "14262"
string(7) "14262"
string(5) "14262"
----------------
string(7) "14262"
string(7) "14262"
string(5) "14262"
----------------
false
try use.
if (strcmp(trim($output['result']), $pid) == 0) die('true');
Comments
Post a Comment