2012-12-15 37 views
-1

可能重複:
How to avoid echo in curl_exec()?解析的文件在頁面迴盪

我解析需要驗證的XML文件。 一切正常,文件正確下載,但XML認證文件的內容打印在html頁面上。我怎樣才能避免這種行爲?

下面是XML文件

 <maxi-xml> 
      <login>Login successful</login> 
     </maxi-xml> 

這裏是捲曲連接

$ch = curl_init(); 
    $cookiefile = tempnam("tmp", "cookies"); 
    curl_setopt($ch, CURLOPT_URL,"http://www.maxithlon.com/maxi-xml/login.php?user=$_SESSION[user]&scode=$_SESSION[password]"); 
    curl_exec($ch); 

    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile); 
    curl_exec($ch); 

    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile); 
    curl_setopt($ch, CURLOPT_URL, "http://www.maxithlon.com/maxi-xml/athletes.php?"); 
    $fp = fopen('xml/'.$_SESSION[teamid].'_athletes.xml', 'w'); 
    curl_setopt($ch, CURLOPT_FILE, $fp); 
    curl_exec($ch); 

回答

4

之前curl_exec把這個

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
+0

謝謝!快速且有幫助:) 編輯,我需要5分鐘才能接受答案 – djpredator17

+0

不客氣。 –