On Wed, 2004-01-21 at 20:19, Chris W wrote: > Robert Cummings wrote: > > >Hmmm, I don't think other programmer's sloppy coding practices are a > >good argument for having to declare variables or against loose typing. > >There are crappy coders in whatever language you use. The good coders > >will do the right thing. If you are concerned about scripts on > >hotscripts.com where the coder doesn't seem to understand the principles > >of security or fully understand what is happening with their variables, > >then perhaps you should be writing the code yourself or hiring someone > >who does understand the language more completely. Caveat Emptor. Part of > >PHPs simplicity and attractiveness is that you DON'T need to declare > >variables, and you DON'T need to do manual casting. Start adding these > >and you may as well be writing Java or C/C++. > > > > > I am going to have to strongly disagree with some of what Rob said. I
Definately not the first *grin*. > agree that sloppy coding of idiots should have not impact on the design > of a programming language. However I see no disadvantages to forcing > you to declaring variables. Even if you are going to have loose type > conversions you can still declare variables and give their intended > type. If this is done the loose type conversion can be done more > intelligently. It also goes a long way to documenting your code. A > section at the top of a source file with a declaration of all variables > and functions used makes provides an easy and consistent way to document > your code. Well named functions and variables names alone, when they > are all spelled out in a logical order at the top of a source file does > a lot to document the code. On top of that there is a HUGE advantage to > even the best programmer. Let me give you a recent example. > > lots of code; > > $Key = "xyz"; > > lots more code here. > > if($key == "xyz"){ > do this stuff; > } > lots more code here; > > I am assuming you found the error pretty quick, but when looking at the I code with ALL errors enabled. This would fire an error as soon as the code ran. So I have no problem with non declared variables. Generally speaking though, I do declare variables at the top of my functions too, but I picked that up from writing C code. 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