Using "global" in the global scope (i.e. "global $Config;") does nothing. 
If something is declared in the global scope of a file and then included 
into another file, it's still global. You don't need to actually say 
"global $whatever" unless you're in a function.

Also, if you're including a file named "CONFIG.inc" from the same directory 
as the script itself, please, please tell me you have your web server set 
up not to serve CONFIG.inc to the outside world. (i.e. you have a .htaccess 
file or something to send DENY to a request for CONFIG.inc or something.) 
Otherwise somebody could just grab http://example.com/CONFIG.inc and see 
it's contents without restriction.

J



Peter J. Schoenster wrote:

> Yeah, seems hokey doesn't it :) ... I think about the same thing in
> the code I use with PHP but I think it's the nature of the beast. But
> a "Best Practices" sounds like a great idea that has passed me by
> or I forgot if I've seen it.
> 
> I've been doing PHP for about a month now and here's how what I'm
> doing:
> 
> <?php
> 
> 
> include_once ( "./CONFIG.inc"); // Config file
> global $Config;
> 
> $question_search_snippet =
> $Config["Snippets"]->Get("question_search_snippet"); $AskUs =
> $Config["Snippets"]->Get("AskUs"); $Slow_question_search_snippet =
> $Config["Snippets"]->Get("Slow_question_search_snippet");
> 
> $body = <<<HTML
> Data Here
> 
> </p>
> HTML;
> 
> 
> $Config["PageBuilder"]->Build($PHP_SELF,$body);
> 
> 
> ?>
> 
> Most pages are either like "modules/cgi-script" or a just a page like
> this one.
> 
> I really hate globals so I cheat and make an array global :).
> 
> 
> My CONFIG.inc makes connections to all "classes" , sets paths
> etc.
> 
> Here is how I handle my input date (not my confusion with & for
> references):
> 
> $input                                        = &ProcessFormData($GLOBALS);
> 
>     function &ProcessFormData(&$GLOBAL_INPUT) {
>         $FormVariables = array();
>         $input = $GLOBAL_INPUT[HTTP_GET_VARS] ?
> $GLOBAL_INPUT[HTTP_GET_VARS] :
> $GLOBAL_INPUT[HTTP_POST_VARS];
>         foreach($input as $Key=>$Value) {
>             if(is_array($Value)) {
>                 foreach($Value as $SubKey=>$SubValue) {
>                     $FormVariables[$Key.$SubKey] = $SubValue;
>                 }
>            }else {
>                $FormVariables[$Key] = $Value;
>            }
>         } # End of foreach($input as $Key=>$Value)
>         return $FormVariables;
> 
>     } # End of function DisplayArrayVariables
> 
> 
> Peter
> http://www.readbrazil.com/
> Answering Your Questions About Brazil


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

Reply via email to