I've got a function, which takes in a string parameter for the name of specific page section, this can either be head or body.
The function looks like this:
private $html = [];
public function doStuff($pageSection, array $views)
{
foreach ($views as $view) {
//Do some other stuff with view
$this->html[$pageSection] .= $view->renderOutput();
}
print_r($this->html);
}
The renderOutput() function from $view returns a string, and isn't throwing any errors.
When trying to add this string to the $this->html array in a specific array key (the $pageSection), I get the following error:
Notice: Undefined index: body in C:\file.php on line 35
While in the next line (print_r($this->html);, the array is filled with all the strings I wanted to add in the right array key, body.
The function get's called like this:
doStuff('body', array(
//Array of views
));
I tried to remove the concatenate operator and just change the string inside the array key, this threw the same error.
How is this happening? Since I already added the array key in the $this->html[$pageSection] part.
Also, how can I fix this problem?
bodyhere. Maybe it's inrenderOutput?print_routpageSectionwhat does it say?