Re: Counter Help
| From: | Simon Garner | Date: | Fri, 23 Feb 2001 04:31:47 +0000 |
| Subject: | Re: Counter Help | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-41260@lists.php.net to get a copy of this message | ||
From: "Chris Lee" <lee@mediawaveonline.com>
> change
>
> $row[count]
>
> to
>
> $row['count']
>
> it thinks the work [count] is some kind of conastant, it doesnt know you
> mean (string) 'count'
>
<rant>
I have noticed a lot of people do not put quotes on their array indexes
(e.g. VBulletin is a prime offender) - imho this is a really bad practice
because your code becomes ambiguous.
Example:
<?php
define("foo", "donkey");
$test = array("foo"=>"orange", "bar"=>"purple");
echo $test[foo];
?>
Now, I think that should print nothing (or an error), because there is no
index matching "donkey" (the value of the constant "foo"). But for some
reason PHP looks for an array index matching the string "foo" as well,
encouraging this kind of sloppy programming.
Regards
Simon Garner