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


PHP XML_Util::getDoctypeDeclaration方法代码示例

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


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

示例1: serialize

 /**
  * serialize data
  *
  * @param mixed $data    data to serialize
  * @param array $options options array
  *
  * @return boolean true on success, pear error on failure
  * @access public
  * @uses XML_Util::getDoctypeDeclaration()
  * @uses XML_Util::getXMLDeclaration()
  * @internal uses error suppression "@settype()"
  */
 function serialize($data, $options = null)
 {
     // if options have been specified, use them instead
     // of the previously defined ones
     if (is_array($options)) {
         $optionsBak = $this->options;
         if (isset($options['overrideOptions']) && $options['overrideOptions'] == true) {
             $this->options = array_merge($this->_defaultOptions, $options);
         } else {
             $this->options = array_merge($this->options, $options);
         }
     } else {
         $optionsBak = null;
     }
     //  start depth is zero
     $this->_tagDepth = 0;
     $rootAttributes = $this->options[XML_SERIALIZER_OPTION_ROOT_ATTRIBS];
     if (isset($this->options[XML_SERIALIZER_OPTION_NAMESPACE]) && is_array($this->options[XML_SERIALIZER_OPTION_NAMESPACE])) {
         $rootAttributes['xmlns:' . $this->options[XML_SERIALIZER_OPTION_NAMESPACE][0]] = $this->options[XML_SERIALIZER_OPTION_NAMESPACE][1];
     }
     $this->_serializedData = '';
     // serialize an array
     if (is_array($data)) {
         if (isset($this->options[XML_SERIALIZER_OPTION_ROOT_NAME])) {
             $tagName = $this->options[XML_SERIALIZER_OPTION_ROOT_NAME];
         } else {
             $tagName = 'array';
         }
         $this->_serializedData .= $this->_serializeArray($data, $tagName, $rootAttributes);
     } elseif (is_object($data)) {
         // serialize an object
         if (isset($this->options[XML_SERIALIZER_OPTION_ROOT_NAME])) {
             $tagName = $this->options[XML_SERIALIZER_OPTION_ROOT_NAME];
         } else {
             $tagName = get_class($data);
         }
         $this->_serializedData .= $this->_serializeObject($data, $tagName, $rootAttributes);
     } else {
         $tag = array();
         if (isset($this->options[XML_SERIALIZER_OPTION_ROOT_NAME])) {
             $tag['qname'] = $this->options[XML_SERIALIZER_OPTION_ROOT_NAME];
         } else {
             $tag['qname'] = gettype($data);
         }
         $tagName = $tag['qname'];
         if ($this->options[XML_SERIALIZER_OPTION_TYPEHINTS] === true) {
             $rootAttributes[$this->options[XML_SERIALIZER_OPTION_ATTRIBUTE_TYPE]] = gettype($data);
         }
         if (!is_bool($data)) {
             $tag['content'] = $data;
         } elseif ($data === false) {
             if ($this->options[XML_SERIALIZER_OPTION_FALSE_AS_STRING] === true) {
                 $tag['content'] = '0';
             } else {
                 $tag['content'] = '';
             }
         } else {
             $tag['content'] = $data;
         }
         @settype($data, 'string');
         $tag['attributes'] = $rootAttributes;
         $this->_serializedData = $this->_createXMLTag($tag);
     }
     // add doctype declaration
     if ($this->options[XML_SERIALIZER_OPTION_DOCTYPE_ENABLED] === true) {
         $this->_serializedData = XML_Util::getDoctypeDeclaration($tagName, $this->options[XML_SERIALIZER_OPTION_DOCTYPE]) . $this->options[XML_SERIALIZER_OPTION_LINEBREAKS] . $this->_serializedData;
     }
     //  build xml declaration
     if ($this->options[XML_SERIALIZER_OPTION_XML_DECL_ENABLED]) {
         $atts = array();
         $this->_serializedData = XML_Util::getXMLDeclaration('1.0', $this->options[XML_SERIALIZER_OPTION_XML_ENCODING]) . $this->options[XML_SERIALIZER_OPTION_LINEBREAKS] . $this->_serializedData;
     }
     if ($this->options[XML_SERIALIZER_OPTION_RETURN_RESULT] === true) {
         $result = $this->_serializedData;
     } else {
         $result = true;
     }
     if ($optionsBak !== null) {
         $this->options = $optionsBak;
     }
     return $result;
 }
开发者ID:retrogamer4ever,项目名称:php-tools,代码行数:94,代码来源:Serializer.php

示例2: serialize

 /**
  * serialize data
  *
  * @access   public
  * @param    mixed    $data data to serialize
  * @return   boolean  true on success, pear error on failure
  */
 function serialize($data, $options = null)
 {
     // if options have been specified, use them instead
     // of the previously defined ones
     if (is_array($options)) {
         $optionsBak = $this->options;
         if (isset($options['overrideOptions']) && $options['overrideOptions'] == true) {
             $this->options = array_merge($this->_defaultOptions, $options);
         } else {
             $this->options = array_merge($this->options, $options);
         }
     } else {
         $optionsBak = null;
     }
     //  start depth is zero
     $this->_tagDepth = 0;
     $this->_serializedData = '';
     // serialize an array
     if (is_array($data)) {
         if (isset($this->options['rootName'])) {
             $tagName = $this->options['rootName'];
         } else {
             $tagName = 'array';
         }
         $this->_serializedData .= $this->_serializeArray($data, $tagName, $this->options['rootAttributes']);
     }
     // add doctype declaration
     if ($this->options['addDoctype'] === true) {
         $this->_serializedData = XML_Util::getDoctypeDeclaration($tagName, $this->options['doctype']) . $this->options['linebreak'] . $this->_serializedData;
     }
     //  build xml declaration
     if ($this->options['addDecl']) {
         $atts = array();
         if (isset($this->options['encoding'])) {
             $encoding = $this->options['encoding'];
         } else {
             $encoding = null;
         }
         $this->_serializedData = XML_Util::getXMLDeclaration('1.0', $encoding) . $this->options['linebreak'] . $this->_serializedData;
     }
     if ($optionsBak !== null) {
         $this->options = $optionsBak;
     }
     return true;
 }
开发者ID:prometheus-ev,项目名称:promdilps,代码行数:52,代码来源:v2.php

示例3: serialize

 /**
  * serialize data
  *
  * @access   public
  * @param    mixed    $data data to serialize
  * @return   boolean  true on success, pear error on failure
  */
 function serialize($data, $options = null)
 {
     // if options have been specified, use them instead
     // of the previously defined ones
     if (is_array($options)) {
         $optionsBak = $this->options;
         if (isset($options["overrideOptions"]) && $options["overrideOptions"] == true) {
             $this->options = array_merge($this->_defaultOptions, $options);
         } else {
             $this->options = array_merge($this->options, $options);
         }
     } else {
         $optionsBak = null;
     }
     // maintain BC
     if (isset($this->options["tagName"])) {
         $this->options["rootName"] = $this->options["tagName"];
     }
     //  start depth is zero
     $this->_tagDepth = 0;
     $this->_serializedData = "";
     // serialize an array
     if (is_array($data)) {
         if (isset($this->options["rootName"])) {
             $tagName = $this->options["rootName"];
         } else {
             $tagName = "array";
         }
         $this->_serializedData .= $this->_serializeArray($data, $tagName, $this->options["rootAttributes"]);
     } elseif (is_object($data)) {
         if (isset($this->options["rootName"])) {
             $tagName = $this->options["rootName"];
         } else {
             $tagName = get_class($data);
         }
         $this->_serializedData .= $this->_serializeObject($data, $tagName, $this->options["rootAttributes"]);
     }
     // add doctype declaration
     if ($this->options["addDoctype"] === true) {
         $this->_serializedData = XML_Util::getDoctypeDeclaration($tagName, $this->options["doctype"]) . $this->options["linebreak"] . $this->_serializedData;
     }
     //  build xml declaration
     if ($this->options["addDecl"]) {
         $atts = array();
         if (isset($this->options["encoding"])) {
             $encoding = $this->options["encoding"];
         } else {
             $encoding = null;
         }
         $this->_serializedData = XML_Util::getXMLDeclaration("1.0", $encoding) . $this->options["linebreak"] . $this->_serializedData;
     }
     if ($optionsBak !== null) {
         $this->options = $optionsBak;
     }
     return true;
 }
开发者ID:automatweb,项目名称:automatweb_sales,代码行数:63,代码来源:Serializer.php


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