PDA

View Full Version : Quick php question (arrays...)


jpt62089
06-22-2005, 06:31 AM
is it good/safe to strucure the config file that defines db connectios (like host, user, pass, etc) like this:

<?php
$dbinfo = array(
'host' => 'localhost',
'dbname' => 'project',
'user' => 'user',
'pass' => 'pass'
)
?>

and when I want to call those I will type (using host as ex.):

<?php
echo $dbinfo['host'];
?>

is this very secure? or is just regular variables safer?

Marco van Herwaarden
06-22-2005, 06:35 AM
From a security point of view, there is no difference between an array and a non-array variable.

jpt62089
06-22-2005, 06:37 AM
what about speed? and any cons to using this method? or more pros to other methods?

sry for the n00b questions... (hey I gotta start somewhere ;))

Dean C
06-22-2005, 08:46 AM
Perhaps this (http://en.wikipedia.org/wiki/Array) may be of some help to you. Personally I'd keep it how you are. Arrays allow you to organize your data structures into groups which is just a nicer way IMO :)