I hate using global variables this way in functions, but it can be done.

<?php
    function test()
    {
        global $HTTP_POST_VARS;
        if ($HTTP_POST_VARS['form'] == 'func')
            foreach($HTTP_POST_VARS as $pos => $val)
                global $pos;
        // reset of your code.
    }
?>

there are good reasons for global variables, but use them wisely, globals
are offten missused and create illegible code. most variables should be
passed as arguments to the function.

--

  Chris Lee
  [EMAIL PROTECTED]


"Siim Einfeldt aka Itpunk" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
> Hi everybody,
>
> Is it possible (and if it is, how) to globalize all the variables, that
> come from some form, automatically?
> For example:
>
> function do_something(){
> global $form;
> if($form != "func"){
> /* globalize all the variables that come from a form
> called $form . How to do it? */
> }
> }
>
> Yes, I could it manually - global $firstname,$lastname,$addres, etc
> etc...but the function is being used by different scripts and I need to
> globalize only these variables that come from that particular form ... and
> all that 'automatically'.
>
> Any ideas?
>
> Thanks,
> Siim Einfeldt
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to