当前位置: 首页>>代码示例>>PHP>>正文


PHP XML_Serializer::setErrorHandling方法代码示例

本文整理汇总了PHP中XML_Serializer::setErrorHandling方法的典型用法代码示例。如果您正苦于以下问题:PHP XML_Serializer::setErrorHandling方法的具体用法?PHP XML_Serializer::setErrorHandling怎么用?PHP XML_Serializer::setErrorHandling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XML_Serializer的用法示例。


在下文中一共展示了XML_Serializer::setErrorHandling方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

<?php

/**
 * This example shows how to create an RDF document
 * with a few lines of code.
 * This can also be done with mode => simplexml
 *
 * @author Stephan Schmidt <schst@php.net>
 * @see    serializeIndexedArray.php
 */
error_reporting(E_ALL);
require_once 'XML/Serializer.php';
$options = array("indent" => "    ", "linebreak" => "\n", "typeHints" => false, "addDecl" => true, "encoding" => "UTF-8");
$serializer = new XML_Serializer($options);
$serializer->setErrorHandling(PEAR_ERROR_DIE);
$array = array(new stdClass(), new stdClass());
$result = $serializer->serialize($array);
if ($result === true) {
    echo "<pre>";
    echo htmlentities($serializer->getSerializedData());
    echo "</pre>";
}
$result = $serializer->serialize($array, array('classAsTagName' => true));
if ($result === true) {
    echo "<pre>";
    echo htmlentities($serializer->getSerializedData());
    echo "</pre>";
}
开发者ID:BackupTheBerlios,项目名称:dilps,代码行数:28,代码来源:serializeArrayWithObjects.php

示例2: serializeArray

/**
 * Return xml version of result set.
 */
function serializeArray($resultList)
{
    $options = array(XML_SERIALIZER_OPTION_XML_DECL_ENABLED => false, XML_SERIALIZER_OPTION_DOCTYPE_ENABLED => false, XML_SERIALIZER_OPTION_INDENT => "    ", XML_SERIALIZER_OPTION_LINEBREAKS => "\n", XML_SERIALIZER_OPTION_TYPEHINTS => false, XML_SERIALIZER_OPTION_XML_ENCODING => "UTF-8?", XML_SERIALIZER_OPTION_ROOT_NAME => "results", XML_SERIALIZER_OPTION_DEFAULT_TAG => "result", XML_SERIALIZER_OPTION_CDATA_SECTIONS => true);
    // instatiate the serializer object
    $serializer = new XML_Serializer($options);
    $serializer->setErrorHandling(PEAR_ERROR_DIE);
    // serialze the data
    $status = $serializer->serialize($resultList);
    // check whether serialization worked
    if (PEAR::isError($status)) {
        die($status->getMessage());
    }
    // get the serialized data
    $xml = $serializer->getSerializedData();
    header("Content-type: text/xml; charset=UTF-8");
    //header("Content-Transfer-Encoding: binary\n");
    // return the xml
    $xml = html_entity_decode($xml, ENT_QUOTES, 'UTF-8');
    $xml = stripslashes($xml);
    $xml = trim($xml);
    echo $xml;
}
开发者ID:raedatoui,项目名称:View,代码行数:25,代码来源:functions.php


注:本文中的XML_Serializer::setErrorHandling方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。