PHP variable with minus in -
i'm modifying script want server stats, i've put server key 1 of variables. fear variable can't have minus within them. true?
see line 3.
// convert lists json $postdata=array(); $postdata['id']="534f7035-cef8-48aa-b233-8d44a0956e68"; // run post request via curl $c2=curl_init('http://api.bf3stats.com/'.$platform.'/server/'); curl_setopt($c2,curlopt_header,false); curl_setopt($c2,curlopt_post,true); curl_setopt($c2,curlopt_useragent,'bf3statsapi/0.1'); curl_setopt($c2,curlopt_httpheader,array('expect:')); curl_setopt($c2,curlopt_returntransfer,true); curl_setopt($c2,curlopt_postfields,$postdata); $id=curl_exec($c2); $statuscode=curl_getinfo($c2,curlinfo_http_code); curl_close($c2); if($statuscode==200) { // decode json data $id=json_decode($id,true); } else { echo "bf3 stats api error status: ".$statuscode; }
your code work fine, however; since you're not parsing variables in string, might use single quotes ('
) instead of double quotes ("
). micro-optimization factor of makes virtually no difference, it'll ensure never have accidental results after modifying string.
Comments
Post a Comment