本文整理汇总了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", ' '));
}
示例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);
}
示例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-
}
示例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;
}
示例5: testTrim
public function testTrim()
{
$string = new String("Test13 ");
$this->assertEquals("Test13", $string->trim());
}
示例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());
示例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("あいうえお"));
}