John, YES! That's what I was looking for. Thanks for the explaination. It helps a great deal. I had $_SERVER['DOCUMENT_ROOT'] work for me. But I'm still struggling with $_SERVER['PHP_SELF'], because it's not returning anything.
So here's the second part to my question stated earlier. Let's say, for example, I had a class included in someFile.php. The included class looks like the class below: <?php class someClass { function someFunction () { $root = $_SERVER['DOCUMENT_ROOT']; return $root; } function someFunction2 () { $path = $this->someFunction() . $_SERVER['PHP_SELF']; return $path; } } ?> Shouldn't the value of $_SERVER['PHP_SELF'] contain the path of someFile.php and not the path of the class file which was included in someFile.php? Or what should this value be? I want the $_SERVER['PHP_SELF'] value to be /path/someFile.php, or the value of whatever page included this class file and called the methods of the class. How would I do that? Because right now it returns a blank string. > -----Original Message----- > From: John W. Holmes [mailto:[EMAIL PROTECTED]] > Sent: Sunday, January 26, 2003 3:37 PM > To: '@ Nilaab'; 'Php-General' > Subject: RE: [PHP] Predefined Variables In Classes > > > > Well, I don't think this has anything to do with predefined variables > > being > > global or not because I only have use for them within the specific > > methods. > > The methods will capture their values and assign them to a variable > inside > > the function, which will return that variable at the end. The > processing > > of > > $PHP_SELF and $DOCUMENT_ROOT only happens in one place. I might be > wrong, > > not sure. But right now all I know is that I am confused and the link > you > > sent me didn't help explain what I need to know because it states no > > mention > > of predefined variables. Can you perhaps give me an example of what > you > > are > > trying to tell me? > > Predefined or not, it's still a variable. If you want a variable inside > of your function to have the value of a variable outside of your > function, then you have to make it global. $PHP_SELF inside of your > function has no value because it's relative to the function, not the > script. Just like $a inside of a function wouldn't have a value unless > you assigned one to it. Using "global $PHP_SELF" at the beginning of > your function (or method, same thing) will now make the variable > $PHP_SELF have the same value as it does outside of your function. > > > I read about variable scope and it says nothing about predefined > > variables. > > So how will using the $_SERVER associate array help me with this? > Remember > > that globals is on, so I don't need to use $_SERVER, $_POST, $_GET, > etc. > > to > > get my values. But, in the meantime I'll go ahead and try using the > > associate autoglobal arrays anyway, like $_SERVER, just to test it and > to > > see if it works for me. And if it does, it'll bug me until I find out > why > > it > > works. Thanks your input Philip. If anyone else has any thoughts or > > explainations for me to understad this then that would be great. > > $_SERVER['PHP_SELF'] will always work, regardless of variable scope or > register_globals setting. The $_SERVER array is a superglobal, so it'll > have the same value inside your method or outside of it, without you > having to do anything special. > > Hope that helps. > > ---John W. Holmes... > > PHP Architect - A monthly magazine for PHP Professionals. Get your copy > today. http://www.phparch.com/ > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php