Re: Does requesting $_SERVER variables need to query the server

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Marc,

$_SERVER is an array and it should have all the information. I do not know
the answer for the latter part of your query.

Regards,
Shreyas

On Thu, Feb 24, 2011 at 12:30 AM, Marc Guay <marc.guay@xxxxxxxxx> wrote:

> This question will probably reveal my lacking knowledge of the
> fundamentals, but I'm a go for it anyway:
>
> When you use a $_SERVER variable, is a query made to the server to get
> the information or is it just sitting in a variable all ready to go?
> Reworded, is there any efficiency gained by storing the data in a
> "local" variable if it's going to be used many times in the script?
> My experience with jQuery has taught me to store $(objects) in local
> variables if they're going to be used repeatedly because the DOM is
> queried every time a jQuery object is generated, so I'm wondering if a
> similar logic applies.
>
> Example:
>
> if ($_SERVER['SCRIPT_NAME'] == 'how.php')
> // do stuff
> if ($_SERVER['SCRIPT_NAME'] == 'why.php')
> // do other stuff
>
> vs.
>
> $script_name = $_SERVER['SCRIPT_NAME'];
>
> if ($script_name == 'how.php')
> // do stuff
> if ($script_name  == 'why.php')
> // do other stuff
>
> Cheerios,
> Marc
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Regards,
Shreyas Agasthya

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux