[nycphp-talk] define variables versus assigned variables
kkrutoi at gmail.com
Sun Jan 3 00:22:50 EST 2010
1. Your defined constants should be all CAPITALIZED.
2. I ran some tests earlier last year (2009) for this and found the following:
- using class constants (and accessing it via
ClassName::ConstantName) was about 30x faster than using define().
- there were about 1000 constants used (it's a pretty big and
- the tests were run using ab (with the top 10% and bottom 10%
edge results thrown out)
- the tests were run with apc and without apc.
Will it make or break your app when it's under stress? Definitely not.
On Sun, Jan 3, 2010 at 12:02 AM, <webmaster at vbplusme.com> wrote:
> Hello ,
> Happy New Year to all,
> I have two statements to make a database connection. One of them
> using define statement variables to parse the information to the
> function to connect to the database, i.e.
> open_connect(db_user, db_pass, db_name, db_host = 'localhost', $show_error=1)
> The second example uses assigned variables, for example,
> open_connect($db_user, $db_pass, $db_name, $db_host = 'localhost', $show_error=1)
> Seems to me that both of these techniques do the same thing so I was
> wondering why one would be any advantage over the other, though I
> just read that the define variables take twice as long to process
> under some conditions. Can some one explain which technique is the
> preferred method or whether or not any compelling reason exist for
> using one over the other?
> Thanks in advanced for any comments.
> Best regards,
> Webmaster mailto:webmaster at vbplusme.com
> New York PHP Users Group Community Talk Mailing List
More information about the talk