echo值并存储为变量

时间:2012-05-29 10:16:34

标签: php curl echo

$ch = curl_init();                   //this part we set up curl 
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$xml_response = curl_exec($ch);
curl_close($ch);
header('Content-type: application/xml');  //specify as xml to not display as one long string
echo $xml_response; 
//header('Content-type: text/plain');  //specify as xml to not display as one long string
$xml = new SimpleXMLElement($xml_response);  //time to echo back the correct piece of data

$editorialReview = $xml->Items->Item->EditorialReviews->EditorialReview->Content;
ob_start();
echo '<p>Editorial review: '.html_entity_decode($editorialReview).'</p>'."\n"; 
$MineNow = ob_get_contents();
ob_end_clean();
var_dump($MineNow);

我想要做的是在回声后我需要将它存储到变量中,以便我可以发布 将数据导入mysql;我尝试使用ob_start会话捕获它,但var_dump没有返回任何vaules !!

1 个答案:

答案 0 :(得分:2)

为什么你不能使用:

$variable = '<p>Editorial review: '.html_entity_decode($editorialReview).'</p>'."\n";
echo $variable;