簡體   English   中英

PHP簡單html dom損壞縮進

[英]PHP simple html dom damaging indentation

我正在使用PHP簡單html dom編輯一些html文件。 問題是,當我保存時,它將刪除所有回車符。 我該如何保存它們? 謝謝

API文檔沒有顯示它們,但是file_get_htmlstr_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)

也許您可以將$stripRN設置$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);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM