Re: array()

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

 



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


If that's your first use of $data then it's not necessary, but it's very highly recommended to do something like:

$data = array();

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

That way you _know_ that $data is "clean" before you start doing anything with it.

It's always a good idea to set any variables you're using to some value, either "", array(), 0, or some default value, before you use them to help keep the "bad guys" out of your scripts.

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