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


PHP Horde_Util::cloneObject方法代码示例

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


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

示例1: convertCharset

 /**
  * Converts a string from one charset to another.
  *
  * Uses the iconv or the mbstring extensions.
  * The original string is returned if conversion failed or none
  * of the extensions were available.
  *
  * @param mixed $input    The data to be converted. If $input is an an
  *                        array, the array's values get converted
  *                        recursively.
  * @param string $from    The string's current charset.
  * @param string $to      The charset to convert the string to.
  * @param boolean $force  Force conversion?
  *
  * @return mixed  The converted input data.
  */
 public static function convertCharset($input, $from, $to, $force = false)
 {
     /* Don't bother converting numbers. */
     if (is_numeric($input)) {
         return $input;
     }
     /* If the from and to character sets are identical, return now. */
     if (!$force && $from == $to) {
         return $input;
     }
     $from = self::lower($from);
     $to = self::lower($to);
     if (!$force && $from == $to) {
         return $input;
     }
     if (is_array($input)) {
         $tmp = array();
         reset($input);
         while (list($key, $val) = each($input)) {
             $tmp[self::_convertCharset($key, $from, $to)] = self::convertCharset($val, $from, $to, $force);
         }
         return $tmp;
     }
     if (is_object($input)) {
         // PEAR_Error/Exception objects are almost guaranteed to contain
         // recursion, which will cause a segfault in PHP. We should never
         // reach this line, but add a check.
         if ($input instanceof Exception || $input instanceof PEAR_Error) {
             return '';
         }
         $input = Horde_Util::cloneObject($input);
         $vars = get_object_vars($input);
         while (list($key, $val) = each($vars)) {
             $input->{$key} = self::convertCharset($val, $from, $to, $force);
         }
         return $input;
     }
     if (!is_string($input)) {
         return $input;
     }
     return self::_convertCharset($input, $from, $to);
 }
开发者ID:ThinhNguyenVB,项目名称:Gradient-Studios-Website,代码行数:58,代码来源:String.php

示例2: getPart

 /**
  * Retrieve a specific MIME part.
  *
  * @param string $id The MIME_Part ID string.
  *
  * @return MIME_Part  The MIME_Part requested, or false if the part
  *                    doesn't exist.
  */
 public function getPart($id)
 {
     $mimeid = $this->getMIMEId();
     /* This will convert '#.0' to simply '#', which is how the part is
      * internally stored. */
     $search_id = $id;
     if (($str = strrchr($id, '.')) && $str == '.0') {
         $search_id = substr($search_id, 0, -2);
     }
     /* Return this part if:
        1) There is only one part (e.g. the MIME ID is 0, or the
           MIME ID is 1 and there are no subparts.
        2) $id matches this parts MIME ID. */
     if ($search_id == 0 || $search_id == 1 && !count($this->_parts) || !empty($mimeid) && $search_id == $mimeid) {
         $part = $this;
     } else {
         $part = $this->_partFind($id, $this->_parts);
     }
     if ($part && $search_id != $id && $part->getType() == 'message/rfc822') {
         $ret_part = Horde_Util::cloneObject($part);
         $ret_part->_parts = array();
         return $ret_part;
     }
     return $part;
 }
开发者ID:techdata,项目名称:as2secure-bundle,代码行数:33,代码来源:Part.php


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