RE: [PHP] $DOCUMENT_ROOT -- didn't work from a class..
| From: | Brian Clark | Date: | Wed, 30 Aug 2000 09:10:01 +0000 |
| Subject: | RE: [PHP] $DOCUMENT_ROOT -- didn't work from a class.. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-14355@lists.php.net to get a copy of this message | ||
Jason Murray wrote:
Well, no, I've never had to use global inside a class. Objects are supposed to have an isolated namespace. Besides, DOCUMENT_ROOT is already a part of $GLOBALS: <?php /* not a class */ function Foo() { return $GLOBALS['DOCUMENT_ROOT']; } print Foo(); ?> I think I need to go to bed, because Maxim just pointed out I left out $this-> in my earlier post, which is why it didn't print. :\ Brian :-)<?php class Foo {Helps if you "global $docRoot" inside the function...var $docRoot = $GLOBALS['DOCUMENT_ROOT'];function Bar() { return $docRoot; }} $obj = new Foo; print $obj->Bar(); ?>