當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。