On Fri, 2004-04-23 at 16:55, Gabe wrote:
> When scripting in a language (such as PHP) that doesn't require you to 
> determine the variable type before you use it, is it still considered 
> good technique to initialize it to the type you're going to use it as? 
> Or is it considered ok to just use it?
> 
> e.g.
> 
> $strText = "";        //initialize
> $strText = "now i'll give it a useful value";

Both of the above would be considered initialization IMHO. Either way,
you're better off from a performance standpoint to not initialize the
variable until you use it, since if the code never gets to the
initialization then you'll have saved some processing time. That said,
if most of my vars are going to be used I generally like to initialize
them all at the top of the function for better readability.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to