相关疑难解决方法(0)

php整理的替代方案?

我使用php tidy来处理我的数据库中的html输入,

$fragment = tidy_repair_string($dom->saveHTML(), array('output-xhtml'=>1,'show-body-only'=>1));
Run Code Online (Sandbox Code Playgroud)

我在我的服务器上打开了这个php_tidy但我的实时服务器不支持整洁,

致命错误:在第587行的/customers/0/5/a/mysite.com/httpd.www/models/functions.php中调用未定义的函数tidy_repair_string()

我可以解决这个问题吗?

php tidy htmltidy

7
推荐指数
4
解决办法
1万
查看次数

php XML DOM将特殊字符转换为&#xYY;

我用AJAX POST发送:

<li><ul class   "zone zCentral ui-sortable"><li><ul class="region rCol3 ui-sortable"><li class="" style=""><div><span class="tc tc_video">574081</span> <span>video: 'Mundo.Hoy': ¿Dónde habré olvidado... mi memoria?</span></div></li></ul></li></ul></li>
Run Code Online (Sandbox Code Playgroud)

我这样做是为了创建XML:

        header('Content-type: text/html; charset=utf-8');       
    if(isset($_POST) && isset($_POST['data']))
    {           
        $data = '<ul id="zone_container" class="ui-sortable">';
        $data .= $_POST['data'];
        $data .= '</ul>';                           

        $dom = new DOMDocument('1.0', 'utf-8');
        $dom->loadXML($data);

        echo $dom->saveXML();                       
        exit();
    }
Run Code Online (Sandbox Code Playgroud)

我得到这个:

<?xml version="1.0"?>
<ul id="zone_container" class="ui-sortable">
    <li><ul class="zone zCentral ui-sortable"><li><ul class="region rCol3         ui-sortable"><li class="" style=""><div><span class="tc tc_video">574081</span>     <span>video: 'Mundo.Hoy': &#xBF;D&#xF3;nde habr&#xE9; olvidado... mi memoria?</span></div>    </li></ul></li></ul></li></ul>
Run Code Online (Sandbox Code Playgroud)

¿Dóndehabréolvidado... mi memoria?

翻译为:

&#xBF;D&#xF3;nde …
Run Code Online (Sandbox Code Playgroud)

php xml hex htmlspecialchars

3
推荐指数
1
解决办法
1718
查看次数

来自xml的php utf-8解码返回问号

我在使用xml时遇到了一些问题.我知道这是一个简单的问题,但我找到的答案并没有解决我的问题.问题是,当我使用php domdocument将é或ä或其他特殊字符添加到我的xml文件时,它将é保存为xE9,将ä保存为xE4.我不知道这是否可以,但是当我想显示输出时,它会在这些地方显示问号.我试了很多.就像删除和添加php domdocument中de xml标头中的编码一样.我也尝试使用file_get_contents并使用php utf-8_decode来获取xml.我尝试使用iso intead,但没有解决我的问题.相反,我有时会得到php xml解析错误.我必须做错事,但是什么?多数民众赞成我的问题以及如何解决这个问题.我的xml文件如下所示:xE9和xE4有黑色背景.

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <row id="1">
    <question>blah</question>
    <answer>blah</answer>
  </row>
  <row id="2">
    <question>xE9</question>
    <answer>xE4</answer>
  </row>
</root>
Run Code Online (Sandbox Code Playgroud)

和我的php xml类的一部分

function __construct($filePath) {
    $this->file = $filePath;
    $this->label = array('Vraag', 'Antwoord');
    $xmlStr = file_get_contents($filePath);
    $xmlStr = utf8_decode($xmlStr);
    $this->xmlDoc = new DOMDocument('1.0', 'UTF-8');
    $this->xmlDoc->preserveWhiteSpace = false;
    $this->xmlDoc->formatOutput = true;
    //$this->xmlDoc->load($filePath);   
    $this->xmlDoc->loadXML($xmlStr);
}       
Run Code Online (Sandbox Code Playgroud)

这是添加新行功能

//creates new xml row and saves it in xml file
function addNewRow($question, $answer) {
    $nextAttr = $this->getNextRowId();
    $parentNode = $this->xmlDoc->documentElement;
    $rowNode = $this->xmlDoc->createElement('row');
    $rowNode = …
Run Code Online (Sandbox Code Playgroud)

php xml encode decode special-characters

3
推荐指数
1
解决办法
2577
查看次数

标签 统计

php ×3

xml ×2

decode ×1

encode ×1

hex ×1

htmlspecialchars ×1

htmltidy ×1

special-characters ×1

tidy ×1