2

我正在将 libtidy 与 php 一起使用。我正在使用 xampp,它显示启用了整洁的支持。但是当我在我的代码中使用它时,它会显示以下警告

repairString() [function.repairString]: Could not load configuration file tidy-file.php

我也尝试使用面向对象的版本,但我再次收到警告

tidy_repair_string() [function.tidy-repair-string]: Could not load configuration file tidy-file.php

我将整洁的代码保存在一个名为tidy-file.php. 看起来像这样

$options = array("output-xhtml" => true,"clean" => true, "drop-proprietary-attributes" => true,"drop-font-tags" => true,"drop-empty-paras" => true,"hide-comments" => true); 
function getXHTML($html)
{
$xhtml=tidy_repair_string($html,$options);
return $xhtml;
}

有什么问题

4

1 回答 1

0

根据您在此处显示的内容,您正在尝试使用在函数外部定义的变量。你需要像这样把它拉进去:

function getXHTML($html)
{
  $options = array("output-xhtml" => true,"clean" => true, "drop-proprietary-attributes" => true,"drop-font-tags" => true,"drop-empty-paras" => true,"hide-comments" => true); 
  $xhtml=tidy_repair_string($html,$options);
  return $xhtml;
}
于 2011-05-28T21:30:32.697 回答