RE: [PHP] Counter Help

From: Date: Sat, 24 Feb 2001 06:16:33 +0000
Subject: RE: [PHP] Counter Help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-41454@lists.php.net to get a copy of this message
Yeah, this is very silly thing using arrays without quotes, I once had this problem - learned it - and sticked to using quotes whenever is not an integrer. advising to everyone, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) maxim@phpbeginner.com www.phpbeginner.com -----Original Message----- From: Simon Garner [mailto:sgarner@expio.co.nz] Sent: Friday, February 23, 2001 1:32 PM To: php-general@lists.php.net Subject: Re: [PHP] Counter Help 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#41454) next »