gpt4 book ai didi

php - 如何在 PHP 5 中启用 XSLT 函数?

转载 作者:可可西里 更新时间:2023-11-01 12:25:34 26 4
gpt4 key购买 nike

我想使用 xslt 将 xml 文件作为 HTML 嵌套列表打印出来,据我所知代码是正确的,但是我遇到了这个错误

Fatal error: Call to undefined function xslt_create()

我认为这意味着尚未启用 xslt 功能。如何在 PHP 中启用这些功能?是否有我需要包含的 php 文件(如 Javascript 库的工作方式)或者它是否更复杂?我由 MediaTemple 托管。

这是我正在使用的 php 代码:

        <?php 

// Allocate a new XSLT processor
$xh = xslt_create();

// Process the document, returning the result into the $result variable
$result = xslt_process($xh, 'armstrong.xml', 'familyToNestedList.xsl');
if ($result) {
print "SUCCESS, sample.xml was transformed by sample.xsl into the \$result";
print " variable, the \$result variable has the following contents\n<br>\n";
print "<pre>\n";
print $result;
print "</pre>\n";
}
else {
print "Sorry, sample.xml could not be transformed by sample.xsl into";
print " the \$result variable the reason is that " . xslt_error($xh) .
print " and the error code is " . xslt_errno($xh);
}

xslt_free($xh);

?>

提前致谢!

最佳答案

根据您的 Linux 发行版,您可以只安装 php5-xsl 模块,将行“extension=php_xsl.so”添加到您的 php.ini 文件,然后重新启动您的 apache2 服务器。

这对我在 Ubuntu 11.10 上有效。您可以在命令行中输入“sudo apt-get install php5-xsl”来安装php5-xml。

关于php - 如何在 PHP 5 中启用 XSLT 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4451042/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com