本文整理匯總了PHP中Str::replaceFirst方法的典型用法代碼示例。如果您正苦於以下問題:PHP Str::replaceFirst方法的具體用法?PHP Str::replaceFirst怎麽用?PHP Str::replaceFirst使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Str
的用法示例。
在下文中一共展示了Str::replaceFirst方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: parseMessage
/**
* @param string $message
* @param string$replace
* @return string
*/
protected function parseMessage($message, $replace = '')
{
if ($replace) {
$message = Str::replaceFirst($replace, '', $message);
}
return trim($message);
}
示例2: replacePath
/**
* @param string $newPath
* @return self
*/
public function replacePath($newPath)
{
if (!$this->url) {
return $newPath;
}
$this->url = Str::replaceFirst($this->getPath(), $newPath, $this->url);
return $this;
}
示例3: replaceFirst
/**
* @deprecated
*/
public static function replaceFirst($search, $replace, $subject)
{
trigger_error(self::NOTICE, E_USER_DEPRECATED);
return Str::replaceFirst($search, $replace, $subject);
}
示例4: getCommandClass
/**
* Gets the Classname to generate from the called class like
* MakeDataObjectCommand => DataObject class
* MakeFormCommand => Form class.
*
* @return string
*/
public function getCommandClass()
{
$class = get_class($this);
$class = Str::replaceFirst('Make', '', $class);
$class = Str::replaceLast('Command', '', $class);
return $class;
}
示例5: testReplaceFirst
public function testReplaceFirst()
{
$this->assertEquals('HEY two tree one', Str::replaceFirst('one', 'HEY', 'one two tree one'));
$this->assertEquals('HEYone two tree', Str::replaceFirst('one', 'HEY', 'oneone two tree'));
$this->assertEquals('one two tree', Str::replaceFirst('nine', 'HEY', 'one two tree'));
}