Best way to implement a data structure in PHP ?
        Posted  
        
            by Double Gras
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Double Gras
        
        
        
        Published on 2010-05-24T16:46:29Z
        Indexed on 
            2010/05/24
            16:51 UTC
        
        
        Read the original article
        Hit count: 248
        
Hi,
I want to use some kind of data structure in PHP (5.2), mainly in order to not pollute the global namespace. I think about two approaches, using an array or a class. Could you tell me which approach is better ?
Thanks
$SQL_PARAMETERS = array (
    'server' => '127.0.0.1',
    'login'  => 'root');
class SqlParameters {
    const SERVER = '127.0.0.1';
    const LOGIN  = 'root';
}
echo $SQL_PARAMETERS['server'];
echo SqlParameters::SERVER;
        © Stack Overflow or respective owner