Home > php教程 > PHP源码 > 在PHP中实现asp.net的StringBuilder类

在PHP中实现asp.net的StringBuilder类

PHP中文网
Release: 2016-05-25 17:11:02
Original
1115 people have browsed it


/********************************************  
  *  
  * 函数名:StringBuilder  
  * 作  用:构造PHP下的StringBuilder类  
  * 作  者:雪狐博客 
  * 来 源 :http://www.xuehuwang.com/
  * 日  期:2011-11-09   
  *  
  ********************************************/
class StringBuilder  
{  
    const LINE="<br/>";  
    protected $list= array(&#39;&#39;);  
       
           
    public function __construct( $str=NULL)  
    {  
        array_push($this->list,$str);  
           
    }  
           
    public function Append($str)  
    {  
        array_push($this->list,$str);  
        return $this;  
    }  
       
    public function AppendLine($str)  
    {  
        array_push($this->list,$str.self::LINE);  
        return $this;  
    }  
       
    public function AppendFormat( $str,mixed $args)  
    {  
        array_push($this->list, sprintf($str,$args));  
        return $this;  
    }  
       
    public function ToString()  
    {  
        return implode("",$this->list);  
    }  
       
    public function __destruct()  
    {  
        unset($this->list);  
    }  
}
Copy after login

                   

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template