smarty icon indicating copy to clipboard operation
smarty copied to clipboard

constants work without prefix with PHP 7.3 and Smarty 3.1.34-dev-6

Open ophian opened this issue 6 years ago • 3 comments

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?

ophian avatar Feb 23 '19 09:02 ophian

It was added before the end of 2014. You can control behavior with SmartySecurity class, if you want to disallow it.

AnrDaemon avatar Feb 21 '20 16:02 AnrDaemon

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.

artcs avatar Feb 21 '20 22:02 artcs

Frankly, I see no real use case for PHP constants in templates outside debugging. Template and config variables are all that matters.

AnrDaemon avatar Feb 23 '20 20:02 AnrDaemon