473,378 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Performance-define Vs. global vars

I'm interested to know which one is better--define or global variables
especially for config stuffs.
For example, osCommerce use something like: define('db_user', 'xx');
whereas phpMyAdmin uses like $config['server']['host'] =
'localhost';
and other few software use $db_pass = 'foo';

I'm much interested to know which one is good. Isn't hash array
like $config['server']['host'] overkill? TIA

--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 17 '05 #1
2 3738
"R. Rajesh Jeba Anbiah" <ng**********@rediffmail.com> wrote in message
news:ab**************************@posting.google.c om...
I'm interested to know which one is better--define or global variables
especially for config stuffs.
For example, osCommerce use something like: define('db_user', 'xx');
whereas phpMyAdmin uses like $config['server']['host'] =
'localhost';
and other few software use $db_pass = 'foo';

I'm much interested to know which one is good. Isn't hash array
like $config['server']['host'] overkill? TIA

--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com


Using define is a little better, since you don't run the risk of the
configuration being tampered with even if your application is running on a
server with register_globals turned on. Having said that, I must say that I
usually use $NAME, so that I can interpolate the value into strings.

In regards to performance, getting a constant should be quicker in theory,
since there's no need to resolve variable scope. The difference is hardly
something that you would lose sleep over though.
Jul 17 '05 #2
"Chung Leong" <ch***********@hotmail.com> wrote in message news:<eq********************@comcast.com>...
I'm interested to know which one is better--define or global variables
especially for config stuffs.
For example, osCommerce use something like: define('db_user', 'xx');
whereas phpMyAdmin uses like $config['server']['host'] =
'localhost';
and other few software use $db_pass = 'foo';

I'm much interested to know which one is good. Isn't hash array
like $config['server']['host'] overkill? TIA


Using define is a little better, since you don't run the risk of the
configuration being tampered with even if your application is running on a
server with register_globals turned on. Having said that, I must say that I
usually use $NAME, so that I can interpolate the value into strings.

In regards to performance, getting a constant should be quicker in theory,
since there's no need to resolve variable scope. The difference is hardly
something that you would lose sleep over though.


Thanks Chung, for your wonderful comments and thoughts.

--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: Brian Patterson | last post by:
I have noticed in the book of words that hasattr works by calling getattr and raising an exception if no such attribute exists. If I need the value in any case, am I better off using getattr...
12
by: Fred | last post by:
Has anyone a link or any information comparing c and c++ as far as execution speed is concerned? Signal Processing algorithms would be welcome... Thanks Fred
12
by: serge | last post by:
I have an SP that is big, huge, 700-800 lines. I am not an expert but I need to figure out every possible way that I can improve the performance speed of this SP. In the next couple of weeks I...
6
by: teedilo | last post by:
We have an application with a SQL Server 2000 back end that is fairly database intensive -- lots of fairly frequent queries, inserts, updates -- the gamut. The application does not make use of...
5
by: Scott | last post by:
I have a customer that had developed an Access97 application to track their business information. The application grew significantly and they used the Upsizing Wizard to move the tables to SQL...
115
by: Mark Shelor | last post by:
I've encountered a troublesome inconsistency in the C-language Perl extension I've written for CPAN (Digest::SHA). The problem involves the use of a static array within a performance-critical...
13
by: bjarne | last post by:
Willy Denoyette wrote; > ... it > was not the intention of StrousTrup to the achieve the level of efficiency > of C when he invented C++, ... Ahmmm. It was my aim to match the performance...
13
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make...
7
by: Michael D. Ober | last post by:
When calling Enqueue, the internal array may need to be reallocated. My question is by how much? In the old MFC array classes, you could tell MFC how many additional elements to add to the array...
1
by: jvn | last post by:
I am experiencing a particular problem with performance counters. I have created a set of classes, that uses System.Diagnostics.PerformanceCounter to increment custom performance counters (using...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.