本文整理汇总了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'));
}