GLOBAL vars

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

GLOBAL vars

Post by shiznatix »

I want to set some global variables in the header file in the $_GLOBAL array then be able to use them in a class. heres what i am doing:

header.php

Code: Select all

$_GLOBAL['sroot'] = 'somthing';
someclass.php

Code: Select all

require_once 'header.php';

class some
{
    function some()
    {
        echo $_GLOBAL['sroot'];
    }
}
but of course I get the undefined variable. how do I work this situation?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

ahhhhh thanks ok got it
Post Reply