Re: array()

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

 



Rory Browne wrote:
You're using a lot of negatives.

nice catch on the double neg Rory :-)



$data = array(); // You should initialise $data to array() for various reasons:
// 1: self_documentation - to anyone who reads your code will be obvious // that $data should contain an empty array // 2: security - if someone goes to // http://yoursite.com/page.php?data[]=something_bad_here and you have // register_globals on(which should be, but not assumed to be, off)





On 8/1/05, Sebastian <sebastian@xxxxxxxxxxxxxxxxxxx> wrote:

is it always necessary to call array() when you do something like this:

mysql_query("SELECT ....");
while($rows .....)
{
  $data[] = $rows;
}

if so, why? i have a habit of never calling array() and someone told me
i shouldn't do this.


Someone told you you shouldn't not call array() - in other words you
should call array(). If I'm reading you correctly then the someone is
right. You should not use a variable without initialising it, unless
it comes from a form, in which case you should not use it without
"cleaning" it.





--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005

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





--
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