What I mean is, by using functions to do the hard work for you, it is 
less common to make an obvious mistake. I have a couple of functions 
that I use in most of my scripts.


securityCheck(); // authenticates the user

dbConnect(); // connects to database with default parameters (in config 

$sql = "SELECT * FROM tblName";
$data = GetData($sql, VARIABLES); // grabs data from db and puts in 
global scope

Now if you compare the above code to something which does all that 
manually, then you'll be typing a heck of an amount. If you have to 
search through a hundred lines of code, it would be more difficult than 
searching through 4 lines of code, don't you think? A lot of errors 
people make are spelling errors.

Like so:

$ymVar = $_GET['myVar'];


$myVar = $HTTP_POST_VAR[myVar];

Now if you did this:

importVars($_POST, 'myVar,foo,bar');

It would be much easier to debug because you only have to look at one 
line, cause you know the function is working. If you don't see it in 
that one line, print_r($GLOBALS); might show you if the var is getting 
transferred, etc.

I know what you're saying about confusing code, where you are putting 
more than one statement in one line is difficult to debug, but thats 
different from targeting spelling errors.


On Sunday, October 6, 2002, at 07:57  AM, Sascha Cunz wrote:

> Am Samstag, 5. Oktober 2002 20:44 schrieb Adam Royle:
>> I very much appreciate the suggestions made by the people on this 
>> list,
>> although for me, when developing, the less typing I have to do, the
>> less errors I am bound to come across, and therefore the less 
>> debugging
>> I must do. (Now, doesn't this seem sensible?)
> Well, have you ever read a perl script? :-)
> The shortest source is not the best in all cases. Consider, that there 
> will be
> times, you must read the source again - well, the easier it is written 
> (and
> structured), the easier you will see again how it works...
> --Sascha

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

Reply via email to