Using PHP inside Smarty template files -
Using PHP inside Smarty template files -
the utilize of php within smarty template files has been possible in previous versions of smarty deprecated.
you can still using backwards compatibility wrapper.
this makes using php within template file possible doing:
{php}echo "hello world";{/php}
does know of problems or issues might cause?
to expand comments given total answer, problem embedding arbitrary php code breaks downwards separation between php , smarty.
since smarty compiles straight php, write in smarty can written in pure php, , may or may not end readable, e.g.
<?= $foo ?>
{$foo}
fine <?php if ( $expr ): ?> hello <?php endif; ?>
{if $expr} hello {/if}
not bad either but <?= htmlspecialchars(strtoupper($foo ?: 'hello')); ?>
{$foo|default:'hello'|upper|escape:html}
bit harder on eye the main advantages see of using smarty (all of voided if utilize {php}
):
the benefit you'd retain if mixed smarty , php parts of smarty syntax more readable php equivalent, modifier illustration showed above.
php smarty
Comments
Post a Comment