Thanks for your time in advance. I am a newbie in php and encountered a strange problem, at least for me it is strange. It is about showing variable in string template. Please see the code below:
public function welcome() {
$data="everyone";
$b = $this->returnTemplate();
$a = "<div>dear $data</div>";
}
public function returnTemplate()
{
return "<div>dear $data</div>";
}
I just thought both $a and $b should be the same value <div>dear everyone</div>
but in fact only $a is while $b is <div>dear </div>
.
That really puzzled me and I wonder why? Could someone please to explain it to me?
Thanks in advance and any feedback is welcome!