简体   繁体   English

无法在Curl中将HTML作为变量发布

[英]Trouble posting HTML as variable in Curl

I am using CURL to post an array. 我正在使用CURL发布数组。 It didn't work without using http_build_query(). 如果不使用http_build_query(),它将无法正常工作。 I set one of the rows in the array like this: 我像这样设置数组中的行之一:

$postVars['key']='
<table style="border-style: solid;" width="850" align="center" bgcolor="#e9e9e9" border="3" bordercolor="#999999" cellpadding="0" cellspacing="0"> 
      <tbody><tr> 
           <td colspan="2" bgcolor="#d3d3d3" height="17">
';

and then do CURL: 然后执行CURL:

$postURL = "https://post.xxx.org".$action;
$postData = http_build_query($postVars);
curl_setopt($ch, CURLOPT_URL, $postURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);

$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
echo $output;

And then things break. 然后事情就破裂了。 When I removed the semi-colon, everything worked great. 当我删除分号时,一切都很好。 Why would I need to escape semi-colons?! 为什么我需要转义分号?!

您可以使用HTML实体

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM