Re: Wierd ass code...
| From: | Ryan A | Date: | Sat, 13 May 2006 20:39:43 +0000 |
| Subject: | Re: Wierd ass code... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-236122@lists.php.net to get a copy of this message | ||
Thanks Rob, Satyam,
I understood the error supression but never came
across arrays where people were creating keys on the
fly like this and incrementing them....just looked a
bit weird to me.
Cheers!
Ryan
--- Robert Cummings <robert@interjinn.com> wrote:
> On Sat, 2006-05-13 at 15:20, Ryan A wrote:
> > Hey,
> > Been reading some other code that I got from the
> net,
> > and have come across some wierd looking code,
> would
> > appreciate it if someone could explain it to me:
> >
> > $hits = array();
> > $bytes = array();
> > $blocked = array();
> > $baps = array();
> > $bapm = array();
> >
> > So far so good.... then further down:
> >
> > // 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'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!
>
> 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.
> |
>
`------------------------------------------------------------'
>
>
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
-----
Fight back spam! Download the Blue Frog.
http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com