- str_replace: documentation ( source)
<?php
trait Plop{
public function getURL($name){
return str_replace('%name%', $name, self::$URL);
}
}
class Test{
use Plop;
protected static $URL = '/plop/%name';
}
echo Test::getURL('test');