Re: [SMARTY] Managing vars not assigned
| From: | boots | Date: | Wed, 20 Oct 2004 18:01:57 +0000 |
| Subject: | Re: [SMARTY] Managing vars not assigned | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-11898@lists.php.net to get a copy of this message | ||
--- 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.