savedomdocument

函式
savedomdocument ( $doc, $filename )
引數
  • (DOMDocument) $doc
    Required:
  • (string) $filename
    Required:
定義位置
相關方法
have_commentsedit_commentget_approved_commentsget_commentthe_comment
引入
2.8.0
棄用
-

savedomdocument函式用來儲存一個用PHP中的DOM操作函式修改過的XML文件: 該函式需要兩個引數:代表XML文件的DOMDocument物件,以及儲存文件的檔名。

將XML文件儲存到檔案中。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function saveDomDocument( $doc, $filename ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
$config = $doc->saveXML();
$config = preg_replace( "/([^r])n/", "$1rn", $config );
$fp = fopen( $filename, 'w' );
fwrite( $fp, $config );
fclose( $fp );
}
function saveDomDocument( $doc, $filename ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid $config = $doc->saveXML(); $config = preg_replace( "/([^r])n/", "$1rn", $config ); $fp = fopen( $filename, 'w' ); fwrite( $fp, $config ); fclose( $fp ); }
function saveDomDocument( $doc, $filename ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
	$config = $doc->saveXML();
	$config = preg_replace( "/([^r])n/", "$1rn", $config );

	$fp = fopen( $filename, 'w' );
	fwrite( $fp, $config );
	fclose( $fp );
}

常見問題

FAQs
檢視更多 >