Sur*_*all 0 php dom simple-html-dom
我正在使用PHP简单的html dom来编辑一些html文件.问题是,当我保存时,它会删除所有回车.我怎样才能保存它们?谢谢
API文档不显示他们,但file_get_html和str_get_html功能有一堆额外的乐趣参数,只需打开simple_html_dom.php:
function file_get_html(
$url, $use_include_path = false, $context=null, $offset = -1,
$maxLen=-1,
$lowercase = true,
$forceTagsClosed=true,
$target_charset = DEFAULT_TARGET_CHARSET,
$stripRN=true,
$defaultBRText=DEFAULT_BR_TEXT)
function str_get_html(
$str,
$lowercase=true,
$forceTagsClosed=true,
$target_charset = DEFAULT_TARGET_CHARSET,
$stripRN=true,
$defaultBRText=DEFAULT_BR_TEXT)
Run Code Online (Sandbox Code Playgroud)
也许你可以设置$stripRN为false,否则会这样做simple_html_dom->prepare():
//before we save the string as the doc... strip out the \r \n's if we are told to.
if ($stripRN) {
$str = str_replace("\r", " ", $str);
$str = str_replace("\n", " ", $str);
}
Run Code Online (Sandbox Code Playgroud)