For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > October 2004 > Re: [SMARTY] Managing vars not assigned









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [SMARTY] Managing vars not assigned
Boots

2004-10-20, 4:08 pm

--- Jordi Canals <jcanals@gmail.com> wrote:
> 1) [...snip...]
> Any other thing that I should consider to totally compliant with
> E_STRICT? (I don't need backwards compatibility as all my servers run
> PHP 5.0.2).


You may want to turn error reporting down to E_ALL when including the
Smarty class and then put it back to E_STRICT afterwards instead of
modifying the Smarty class directly. While Smarty is compatible with
PHP5, it is not fully compliant so using E_STRICT against it is not
appropriate, IMO.

> 2) Thats about the templates. I've seen on ones not made by me two
> ways to check is a template var is empty or not assigned: In some
> templates there is:
>
> {if $varname != ''}
> do stuff
> {/if}
>
> while in other templates you can see:
>
> {if !empty($varname)}
> do stuff
> {/if}
>
> Wich method is better? I prefer checking for empty($varname) (as
> normally are vars not being assigned by the script) but want to know
> if there is some better way to do it.


Either is fine; just keep-in-mind PHP's evaluations for $foo=0:
empty($foo) => true
$foo == '' => true
$foo === '' => false

xo boots

> Thanks for any comments,
> Jordi.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com