AW: [PHP-DEV] Bug #11572: global variables cannot be accessed from an objects function?
| From: | Florian Grimm | Date: | Wed, 20 Jun 2001 20:20:21 +0000 |
| Subject: | AW: [PHP-DEV] Bug #11572: global variables cannot be accessed from an objects function? | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-57455@lists.php.net to get a copy of this message | ||
Sure
this is a problem of all languages
function a(){
b();
}
function b(){
a();
}
also creates an infinite loop
PHP cannot set a variable to something the have to create first
but how about
class a {
function a() {
if(!isset($GLOBALS["b"])) {
echo "loading b";
$GLOBALS["b"] = "dummy"
$GLOBALS["b"] = new b();
}
}
}
class b {
function b() {
if(!isset($GLOBALS["a"])) {
echo "loading a";
$GLOBALS["a"] = "dummy"
$GLOBALS["a"] = new a();
}
}
}
# creates an NOT infinite loop
new a();
Flori
-----Ursprüngliche Nachricht-----
Von: vincev@gmx.de [mailto:vincev@gmx.de]
Gesendet: Mittwoch, 20. Juni 2001 07:44
An: php-dev@lists.php.net
Betreff: [PHP-DEV] Bug #11572: global variables cannot be accessed from
an objects function?
From: vincev@gmx.de
Operating system: debian linux
PHP version: 4.0.4pl1
PHP Bug Type: Variables related
Bug description: global variables cannot be accessed from an objects
function?
class a {
function a() {
if(!isset($GLOBALS["b"])) {
echo "loading b";
$GLOBALS["b"] = new b();
}
}
}
class b {
function b() {
if(!isset($GLOBALS["a"])) {
echo "loading a";
$GLOBALS["a"] = new a();
}
}
}
# creates an infinite loop
new a();
--
Edit Bug report at: http://bugs.php.net/?id=11572&edit=1
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net
For additional commands, e-mail: php-dev-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net