-
Jul 26th, 2009, 01:43 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Define or Variable(For languages, config....)
Hi,
What is the best choice for languages, config., settings &...?
Define or Variable? Why?
Thanks, regards.
-
Jul 26th, 2009, 04:56 AM
#2
Re: Define or Variable(For languages, config....)
I don't understand what you're trying to ask at all.
-
Jul 26th, 2009, 05:14 AM
#3
Thread Starter
Addicted Member
Re: Define or Variable(For languages, config....)
For example, this is my database config.: host, port, username, password...
What is the best choice? Define or Variable?
define('Host', '127.0.0.1');
define('Port', 3306);
define('Username', 'root');
define('Password', '');
or
$cfg['Host']= '127.0.0.1';
$cfg['Port']= 3306;
$cfg['Username']= 'root';
$cfg['Password']= '';
??
-
Jul 26th, 2009, 09:33 AM
#4
Re: Define or Variable(For languages, config....)
Defined constants have global scope, and cannot be changed in the script. Therefore they ought to be data that meets those criteria: globally used values that will not need to change. For your example, I would say define is more appropriate (though I would use more specific naming, like "DB_USERNAME" - also the naming convention for constants is all caps).
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|