|
Posted by Rory Browne on 08/02/05 22:05
You're using a lot of negatives.
$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@broadbandgaming.net> 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
>
>
Navigation:
[Reply to this message]
|