I'm need to concatenate lines for later output (markdown processing...). This is why I use a function l()
and a global variable $content
.
My view code:
$content = "";
function l($line="") {
global $content;
$content .= $line."
";
}
l("hello");
echo "+";
echo $content;
echo "-";
outputs
+-
I'd expect:
+Hello-
Why? What am I doing wrong?
I am using PHP 7.2.6
EDIT:
There are several PHP related answers as this one. But they don't help. I suppose the problem is related to Yii2 and more specific to Yii2 view handling.