[phpa] define vs globals

Hello,

the 2 funtions below accomplish the same:

$test = "hello world";
define("TEST", "hello world");

function myfunc1()
{
   global $test;
   echo $test;
}

funtion myfunc2()
{
   echo TEST;
}

I remember from my C-programming days that a define was often better, 
because it was replaced by the value at compile time.

Because PHP compiles a script each time it is requested, I never saw 
this as an issue. But now I was wondering whether this would make a 
difference when using php-accelerator. Since the accelerator stores the 
compiled code, I'm wondering if using defines is significantly faster 
(assuming that I'm using a lot of them, for language files in my 
application) than using global variables? Or does PHP handle defines the 
same as global variables internally?

Greetings,
Ivo

-- 
Ivo Jansch <ivo@xxxxxxxxxxxxx>
ibuildings.nl BV - information technology
http://www.ibuildings.nl

------------------------------------------------------------------------
  www.php-accelerator.co.uk           Home of the free PHP Accelerator

To post, send email to phpa@xxxxxxxxxxxxx
To unsubscribe, email phpa-request@xxxxxxxxxxxxx with subject unsubscribe


Other related posts: