I want the variable to be parsed within the array so when I echo $head[‘meta_title’] , lol is displayed. I have tried wrapping it in double quotes but that doesn’t seem to work either, is there any way round this?? Thanks!
I am getting either unexpected T_VARIABLE and when I use double quotes I get unexpected “”
$meta_title = "lol";
public $head = array
(
"title" => "blah",
"meta_title" => $meta_title,
"meta_content" => $meta_content
);
You cannot use an expression to initialize a class property. The values of the two variables are not known until runtime, and therefore can’t be used in the declaration. Instead, define them in the constructor.
From the docs