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


PHP String::trim方法代码示例

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


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

示例1: sanitize

 /**
  * Filter: removes unnecessary whitespace and shortens value to control's max length.
  * @return string
  */
 public function sanitize($value)
 {
     if ($this->control->maxlength && iconv_strlen($value, 'UTF-8') > $this->control->maxlength) {
         $value = iconv_substr($value, 0, $this->control->maxlength, 'UTF-8');
     }
     return String::trim(strtr($value, "\r\n", '  '));
 }
开发者ID:jaroslavlibal,项目名称:MDW,代码行数:11,代码来源:TextInput.php

示例2: renderFile

 private static function renderFile(&$loader, $origTempUri, $origTempPath, $key, $files)
 {
     $controlId = basename(substr($key, 0, strpos($key, '||')));
     // ak je to nejaky subor z modulu [vzdy ulozeny v zlozke 'web'], tak chceme zachovat meno podla 3.parametra
     if ($controlId == 'web') {
         $dirname = substr($key, strpos($key, '||') + 2);
         $pathSuffix = Basic::getBaseDirName($dirname);
         $srcPath = str_replace(array('||', $pathSuffix . '/'), array('', ''), $key);
     } else {
         $dirname = $controlId . '/' . substr($key, strpos($key, '||') + 2);
         $srcPath = str_replace('||', '', $key);
     }
     $dirname = String::trim($dirname, '/');
     //todo: overit, ci to nebude robit adresare zase inde..zistit, cim to je, ze to na locale ide a na ostrom serveri nie
     // pouzit ked tak Environment::getVariable('webtempDir')
     Basic::mkdir($origTempPath . '/' . $dirname);
     $loader->sourcePath = $srcPath;
     $loader->tempUri = $origTempUri . '/' . $dirname;
     $loader->tempPath = $origTempPath . '/' . $dirname;
     $loader->render($files);
 }
开发者ID:radypala,项目名称:maga-website,代码行数:21,代码来源:MyWebloader.php

示例3: testTrim

 /**
  * trim test.
  * @return void
  */
 public function testTrim()
 {
     $this->assertEquals("x", String::trim(" \t\n\r\v x"));
     $this->assertEquals("", String::trim("�x�"));
     $this->assertEquals("a b", String::trim(" a b "));
     $this->assertEquals(" a b ", String::trim(" a b ", ''));
     $this->assertEquals("e", String::trim("Ře-", "Ř-"));
     // Ře-
 }
开发者ID:vrana,项目名称:nette,代码行数:13,代码来源:NetteStringTest.php

示例4: setPlainMessage

 /**
  * Sets the plain message.
  *
  * @param string $message
  * @return Email
  */
 public function setPlainMessage($message)
 {
     if (!$message instanceof String) {
         $message = new String($message);
     }
     $this->messages["plain"] = $message->trim()->regEx("#(\r\n|\r|\n)#", $this->headerSeparator);
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:14,代码来源:Email.util.php

示例5: testTrim

 public function testTrim()
 {
     $string = new String("Test13 ");
     $this->assertEquals("Test13", $string->trim());
 }
开发者ID:seanyainkiranina,项目名称:completecontrol,代码行数:5,代码来源:stringtest.class.php

示例6: __construct

<?php

class String
{
    private $_string;
    public function __construct($string)
    {
        $this->_string = $string;
    }
    public function __call($method, $arguments)
    {
        $this->_string = call_user_func($method, $this->_string);
        return $this;
    }
    public function getValue()
    {
        return $this->_string;
    }
}
$test = new String('  test, test2 ');
$test->trim();
var_dump($test->getValue());
$test->strlen();
var_dump($test->getValue());
开发者ID:billfeller,项目名称:frontfunc,代码行数:24,代码来源:String.php

示例7: testTrim

    public function testTrim()
    {
        $string = new String("  Hello World  ");
        $this->assertTrue($string->trim()->equals("Hello World"));
        $string = new String("/*/*/Hello World/*/*/");
        $this->assertTrue($string->trim("/*")->equals("Hello World"));
        $str = <<<STR
  
  aiueo
  

  
STR;
        $string = new String($str);
        $this->assertTrue($string->trim()->equals("aiueo"));
        // multibyte
        $string = new String("  あいうえお  ");
        $this->assertTrue($string->trim()->equals("あいうえお"));
        $string = new String("表能申あいうえお申能表");
        $this->assertTrue($string->trim("表能申")->equals("あいうえお"));
        $str = <<<STR
    
  あいうえお  
    


    

 
STR;
        $string = new String($str);
        $this->assertTrue($string->trim()->equals("あいうえお"));
    }
开发者ID:reoring,项目名称:sabel,代码行数:33,代码来源:String.php


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