Closed wisskid closed 5 months ago
Just a quick question, the following code will be supported in the next version of Smarty or not?
{foreach item=column from=range('A', 'Z')}
...
{/foreach}
Works with Smarty 4.3.4.
Thanks
Just a quick question, the following code will be supported in the next version of Smarty or not?
{foreach item=column from=range('A', 'Z')} ... {/foreach}
Yes, Smarty 5 still supports the 'old' foreach syntax, @vojtasvoboda .
The question was about calling the native PHP function range() (and also about other native PHP functions), sorry for the incomplete description :-) @wisskid
{foreach range('A', 'Z'} as $column}
...
{/foreach}
The question was about calling the native PHP function range() (and also about other native PHP functions), sorry for the incomplete description :-) @wisskid
{foreach range('A', 'Z'} as $column} ... {/foreach}
Well, my answer wasn't very complete either... :-) The range function is currently not implemented in v5.0.0-rc2 so it would have to be added as a custom extension. But if you feel that it is important, I would be open to add it to the DefaultExtension set. @vojtasvoboda
@wisskid But the range() function is not implemented in v4.3.4 either and works well (i didn't find any range mention in the whole repository) :-) I thought Smarty just call global functions (and also native PHP functions) without any extra definition.
For example when I create a custom global function my_custom_strtoupper(string $name) and call:
{my_custom_strtoupper('Vojta')}
It works.
So in Smarty 5.x.x calling existing functions (and also native PHP functions) will be disabled?
Yes, that is correct. @vojtasvoboda more specifically: you can still use them, but you'll have to register them first or include them in a custom extension.
how to disabled this?
You cannot and should not, but you can configure your error reporting and/or logging to ignore deprecation notices.
Could you tell us what is the recommended way for accessing constants or class constants ? Same for static method call
... because we will drop support for this in the next major release
Fixes #813