smarty
smarty copied to clipboard
constants work without prefix with PHP 7.3 and Smarty 3.1.34-dev-6
Since I am using PHP 7.3, I realised that defined constants actually work as {EXAMPLE}
right out the box, without the $smarty.const.
prefix.
Is that an intentionell Smarty behaviour to be kept in future or is this PHP just being smart?
It was added before the end of 2014. You can control behavior with SmartySecurity class, if you want to disallow it.
You can control behavior with SmartySecurity class, if you want to disallow it.
That's not a helpful answer to the question. You only can disallow the use of php constants alltogether via Smarty_Security, so that neither {EXAMPLE}
nor {$smarty.const.EXAMPLE}
will work. There is currntly no hack-free way to disallow only {EXAMPLE}
while keeping {$smarty.const.EXAMPLE}
working.
See the discussion in the above mentioned issue.
Frankly, I see no real use case for PHP constants in templates outside debugging. Template and config variables are all that matters.