Re: Wierd ass code...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>
> // Add to the running totals
> @$hits["$username|$subnet"]++;
> @$bytes["$username|$subnet"]+=$byte;
> @$baps["$username|$subnet|$this_second"]++;
> @$bapm["$username|$subnet|$this_minute"]++;
>
> What kind of arrays are the above? I have never seen
> nor worked with arrays like them before.
>
> If you can point me to a particular place in the
> manual or a few URLs too would be appreciated.

It looks like the code was written by  an awk programmer, or a programmer of
some language that doesn't natively support multidimensional assoc arrays.

It's just a normal array.. but the author is creating keys on the fly
for which the values area being incremented. And because there's no
error checking for the key not existing previously, he has used the
dirty error suppression operator. BAD BAD BAD CODER! Remember, if an
error occurs and you have a custom error handler, your custom error
handler still gets invoked. OWWIE!


I would submit that the error suppression operator isn't BAD BAD BAD per se
- it's just like goto, in that 99% of its use is bad. In the absence of a
comment justifying it, the error-suppressed expression is BAD.

There are some cases where the Error Suppression operator may be useful in
good code. I wouldn't use it to suppress anything more serious than
E_NOTICE. I don't think I ever used this operator, but if I did, i'd explain
why there is no possible case where the code could emit an E_WARNING or
higher.


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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux