Re: default extension for includes?

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

 



Justin French wrote:
On 23/11/2004, at 12:44 PM, Jake Press wrote:

Justin,

'Use the force luke' - or perhaps just write yourself a function to do this :)


Sadly, included files inside functions don't inherit the global namespace, so you have to do something ridiculous like extract($GLOBALS) inside the function:

function includer($thing)
    {
    extract($GLOBALS);
    include($thing.".inc");
    }

The extract isn't too expensive, but it's definitely something I'd like to avoid if possible.

This would not work, extract creates a copy of the variables, changing them in $thing . '.inc' will have no efect outside of the file. You would have to loop $GLOBALS and assign by reference, while skipping superglobals.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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