0

I'm still learning PHP, currently learning the best practices, below I'm requiring in the template file I've been working on, but now I'd like for it to be inside a directory, instead of using templates/templates.php I'd like to define it once from my config file then call it on my index file below. If anyone could point me in the right direction that would be much appreciated, thank you

Edit: I'd like to use the define function, thank you.

index.php

require_once 'config.php';

require_once '$TEMPLATES/template.php';

$tpl = new Template\template('main.tpl');

$tpl->set('city', 'London');

$tpl->render();

config.php

*mysql_details*

$TEMPLATES = 'templates/';

1 Answers1

3

Single quotes don't parse variables the same way double quotes do, either use single quotes without the variable surrounded by the quotes or use double quotes with the variable inside.

Secondly, consider using an actual define.

Reading Material

Strings

Script47
  • 14,230
  • 4
  • 45
  • 66
  • Can you clarify why single quotes are different than double quotes, and why this is a specific issue to this case? – Blue Mar 20 '19 at 10:04