2
我正在使用libtidy和php。我正在使用xampp,它顯示啓用了整潔的支持。但是,當我在我的代碼中使用它,然後它會顯示以下警告libtidy不能在php中工作
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;
}
什麼都可以錯
謝謝,這工作。但是一個函數可以訪問全局數據,這裏'$ options'是一個全局數組。那麼爲什麼沒有工作? – lovesh 2011-05-28 21:39:55
是否遵循不同的作用域規則而不是c/C++ – lovesh 2011-05-28 21:49:08
@lovesh是的,爲了使全局變量在函數作用域中可用,必須使用'global'語句來像這樣拉入它:'global $ options; '。這樣做後,它將可用於該功能。 – 2011-05-28 22:01:54