#21868 [Opn->Bgs]: include()/require() bug

From: Date: Fri, 24 Jan 2003 22:09:17 +0000
Subject: #21868 [Opn->Bgs]: include()/require() bug
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-31183@lists.php.net to get a copy of this message
ID: 21868 Updated by: moriyoshi@php.net Reported By: omikorn@yahoo.com -Status: Open +Status: Bogus Bug Type: Unknown/Other Function Operating System: Windoze PHP Version: 4.2.1 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php You should use "global" declarations when you want to use global variables in the functions. Previous Comments: ------------------------------------------------------------------------ [2003-01-24 15:57:30] omikorn@yahoo.com A BIG ATTENTION! let`s say that we have this 2 files include.php & test.php: include.php <? $foo="blabla"; ?> and now test.php: <? require "include.php"; function do_test() { if ($foo) {echo "foo is set if called from function<br>";} else {echo "bang foo is not set if called from function<br>";} } do_test(); if ($foo) {echo "foo is set if called from main<br>";} else {echo "bang foo is not set if called from main<br>";} Result of the program is: bang foo is not set if called from function. foo is set if called from main Bug? Server: Apache/1.3.26 (Win32) PHP/4.2.3 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=21868&edit=1

« previous php.bugs (#31183) next »