2009-07-20 88 views
0
ob_start(); 
echo '<'.'?xml version="1.0"?'.'>'; 
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'; 
echo '<root>'; 
$hierarchy=$tree->getArray(); 
recursiveBuild($hierarchy[0]); 
echo '</root>'; 
file_put_contents('file.xml', ob_get_contents()); 
ob_end_clean(); 

file_put_contents('file.xml', 'w+' ob_get_contents()); 

這是行不通的,它不會自動更新xml文件。在php和xml文件寫入權限

+1

你究竟是什麼意思,它沒有自動更新? – Gumbo 2009-07-20 13:46:38

回答

2

file_put_contents('file.xml', 'w+' ob_get_contents()); 

應以下沒有任何有效的分隔字符串產生一個解析錯誤,因爲ob_get_contents的。順便說一句,你不必爲file_put_contents指定'w +'(並且即使你想要,你也不能),這是隱含的。因此,您應該更換該行:

file_put_contents('file.xml', ob_get_contents()); 

您可能會看到file_ put_contents文檔。