Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Long story short, I need access to every variable in a function. i.e.:
    Code:
    function doit()
    {
        global $a, $b, $c, $d...;
    }
    So is there a way to make every variable global? Using $_GLOBALS['whatever'] is not a realistic solution, either.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  2.  

  3. #2
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    Don't think there is a way to do it. However, if it makes it any easier, try following strict variable declaration, i.e. like C/C++ declare everything you need upfront. Then you can make them global there, using "global" keyword.
    There and Back Again :Ogre:

  4. #3
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Well the problem is this function doesn't know what variables it needs and doesn't need the same ones all the time.

    FWIW this is for a template engine and this function replaces variables with their values.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  5. #4
    Junior Member Kriek's Avatar
    Join Date
    Mar 2003
    Location
    Florida
    Posts
    16
    Member #
    828
    Originally posted by filburt1
    So is there a way to make every variable global?
    Place the vars into an array which will return global status.

    PHP Code:
    <?php
        
    function doit() {
            foreach (
    array_keys($GLOBALS) as $vars) {
                if (!isset($ {
                    
    $vars }
                )) global $ {
                    
    $vars };
            }
        }
        
    doit();
    ?>
    Everyone remain calm, I've done this before.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:39 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com