Afternoon guys!
For some reason Complex (Curly) Syntax in my PHP code doesn't interpreter as variable
function view($name, $data = [])
{
require __DIR__ . '/../app/views/{$name}.view.php';
}
Here is the code I am calling view('index'); the problem is I get this error:
Warning: require(./core/../app/views/{$name}.view.php): failed to open stream
By the way my PHP version before anyone asks is 7.0.13
Thanks for your help!
Your string has to be placed in double quotes (") instead of single quotes ('). Otherwise variables won't be replaced.
Look here: https://secure.php.net/manual/en/language.types.string.php#language.types.string.syntax.single