No, it not possible the way you want it to working.
Other solutions:
function
function mySentence($name) {
return 'Your name is '. $name;
}
Any other replace string
sprintf('"Your name is %s', $name);
str_replace('{name}', $name, 'Your name is {name}');
Sentence as object
Create class that holds main sentance as ValueObject
class Sentence {
private $sentence;
private $name;
public function __constructor($name, $sentence){
$this->name = $name;
$this->sentence = $sentence;
}
public function changeName($name){
return new Sentence($name, $this->sentence);
}
public function printText() {
return $this->sentence . $this->name;
}
public function __toString(){
return $this->printText();
}
}
Then use simply:
$sentence = new Sentence('Fred', "My name is");
echo $sentence;
// My name is Fred
echo $sentence->changeName('John');
// My name is John
This is of course idea, what options you have to resolve this.
With that, you can add any replaceable placeholders etc.