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


PHP General::repeatStr方法代码示例

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


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

示例1: padString

 function padString($str, $length, $spacer = " ", $align = "left")
 {
     switch ($align) {
         case "right":
             return $str . General::repeatStr($spacer, $length - strlen($str));
             break;
         case "center":
             return General::repeatStr($spacer, ($length - strlen($str)) * 0.5) . $str . General::repeatStr($spacer, ($length - strlen($str)) * 0.5);
             break;
         case "left":
         default:
             return General::repeatStr($spacer, $length - strlen($str)) . $str;
             break;
     }
 }
开发者ID:symphonycms,项目名称:symphony-1.7,代码行数:15,代码来源:class.general.php

示例2: generate

 public function generate($indent = false, $tab_depth = 0, $hasParent = false)
 {
     $result = NULL;
     $newline = $indent ? self::CRLF : NULL;
     if (!$hasParent) {
         if ($this->_includeHeader) {
             $result .= sprintf('<?xml version="%s" encoding="%s" ?>', $this->_version, $this->_encoding) . $newline;
         }
         if ($this->_dtd) {
             $result .= $this->_dtd . $newline;
         }
         if (is_array($this->_processingInstructions) && !empty($this->_processingInstructions)) {
             $result .= implode(self::CRLF, $this->_processingInstructions);
         }
     }
     $result .= ($indent ? General::repeatStr("\t", $tab_depth) : NULL) . '<' . $this->_name;
     if (count($this->_attributes) > 0) {
         foreach ($this->_attributes as $attribute => $value) {
             if (strlen($value) != 0 || strlen($value) == 0 && $this->_allowEmptyAttributes) {
                 $result .= sprintf(' %s="%s"', $attribute, $value);
             }
         }
     }
     $numberOfchildren = $this->getNumberOfChildren();
     if ($numberOfchildren > 0 || strlen($this->_value) != 0 || !$this->_selfclosing) {
         $result .= '>';
         if ($this->_value != NULL && !$this->_placeValueAfterChildElements) {
             $result .= $this->_value;
         }
         if ($numberOfchildren > 0) {
             $result .= $newline;
             foreach ($this->_children as $child) {
                 if (!$child instanceof self) {
                     throw new Exception('Child is not of type XMLElement');
                 }
                 $child->setElementStyle($this->_elementStyle);
                 $result .= $child->generate($indent, $tab_depth + 1, true);
             }
             if ($indent) {
                 $result .= str_repeat("\t", $tab_depth);
             }
         }
         if ($this->_value != NULL && $this->_placeValueAfterChildElements) {
             if ($indent) {
                 $result .= str_repeat("\t", max(1, $tab_depth));
             }
             $result .= $this->_value . $newline;
         }
         $result .= "</{$this->_name}>{$newline}";
         // Empty elements:
     } else {
         if ($this->_elementStyle == 'xml') {
             $result .= ' />';
         } else {
             if (in_array($this->_name, $this->_no_end_tags) || substr($this->_name, 0, 3) == '!--') {
                 $result .= '>';
             } else {
                 $result .= "></{$this->_name}>";
             }
         }
         $result .= $newline;
     }
     return $result;
 }
开发者ID:bauhouse,项目名称:sym-calendar,代码行数:64,代码来源:class.xmlelement.php

示例3: generate

 function generate($indent = false, $tab_depth = 0)
 {
     $result = "";
     $newline = $indent ? "\n" : "";
     if ($this->_includeHeader) {
         $result .= '<?xml version="' . $this->_version . '" encoding="' . $this->_encoding . '" ?>' . $newline;
     }
     $result .= ($indent ? General::repeatStr("\t", $tab_depth) : "") . "<" . $this->_name;
     if (count($this->_attributes) > 0) {
         foreach ($this->_attributes as $attribute => $value) {
             if ($value != NULL) {
                 $result .= " {$attribute}=\"{$value}\"";
             }
         }
     }
     $numberOfchildren = $this->getNumberOfChildren();
     if ($numberOfchildren > 0 || $this->_value != NULL) {
         $result .= ">";
         if ($this->_value != NULL) {
             $result .= $this->_value;
         }
         if ($numberOfchildren > 0) {
             $result .= $newline;
             foreach ($this->_children as $child) {
                 $result .= $child->generate($indent, $tab_depth + 1);
             }
             if ($indent) {
                 $result .= General::repeatStr("\t", $tab_depth);
             }
         }
         $result .= "</" . $this->_name . ">" . $newline;
     } else {
         $result .= " />" . $newline;
     }
     return $result;
 }
开发者ID:symphonycms,项目名称:symphony-1.7,代码行数:36,代码来源:class.xmlelement.php


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