我有一个自定义函数说<?php this_content('Main heading'); ?>
,我想在我的xsl里面添加,看起来像这样:
<xsl:template match="page" mode="body">
</xsl:template>
我设置了registerPHPFunctions(),但这仅适用于php内部函数..?
答案 0 :(得分:6)
不,它适用于您定义的功能。确保已将php命名空间添加到打开的XSL标记中,如下所示:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:php="http://php.net/xsl">
然后,您可以使用php:function('function_name', ...)
调用PHP函数。
(你不能像在.php文件中那样嵌入PHP代码块。)
有关详细信息,请参阅the PHP man page for registerPHPFunctions()上的示例和评论。