XSLT (PHP 4) 函数
在线手册:中文 英文
PHP手册

xslt_error

(PHP 4 >= 4.0.3)

xslt_errorReturns an error string

说明

string xslt_error ( resource $xh )

Returns a string describing the last error that occurred on the passed XSLT processor.

参数

xh

The XSLT processor link identifier, created with xslt_create().

返回值

Returns the error message, as a string.

范例

Example #1 Handling errors using the xslt_error() and xslt_errno() functions.

<?php

$xh 
xslt_create();
$result xslt_process($xh'dog.xml''pets.xsl');
if (!
$result) {
    die(
sprintf("Cannot process XSLT document [%d]: %s",
                
xslt_errno($xh), xslt_error($xh)));
}

echo 
$result;

xslt_free($xh);
?>

参见


XSLT (PHP 4) 函数
在线手册:中文 英文
PHP手册
PHP手册 - N: Returns an error string

用户评论:

mikes at ayeltd dot biz (05-Jan-2004 01:18)

There may be cases where a null $result is legitimate, in this case add a test for non-zero xlst_errno:

<?php

$xh
= xslt_create();
$result = xslt_process($xh, 'dog.xml', 'pets.xsl');
if (!
$result && xslt_errno($xh) > 0) {
   die(
sprintf("Cannot process XSLT document [%d]: %s",
              
xslt_errno($xh), xslt_error($xh)));
}

echo
$result;

xslt_free($xh);
?>