RE: [PHP] include, include_once bug or feature ?
| From: | Matt Friedman | Date: | Thu, 14 Mar 2002 14:04:09 +0000 |
| Subject: | RE: [PHP] include, include_once bug or feature ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-88492@lists.php.net to get a copy of this message | ||
I think that since you are including a file into a function - the vars
become local so they only exist when the function is running. Therefore,
a call to get_defined_vars will not show them since the vars do not
exist in the global scope. In fact, during the call to get_defined_vars,
the included vars do not exist at all.
This is a feature, not a bug.
Matt Friedman
Web Applications Developer
www.SpryNewMedia.com
Email: matt@SpryNewMedia.com
-----Original Message-----
From: Pavel Plesov [mailto:mclap@simtts.mv.ru]
Sent: Thursday March 14, 2002 7:56 AM
To: php-general@lists.php.net
Subject: [PHP] include, include_once bug or feature ?
Hello!
I have a trouble :(
When I try this:
--[index.php]--
<?php
function f($action)
{
switch($action){
case 'one': include_once('M/one.php'); break;
}
}
f('one');
?>
--------------
--[M/one.php]--
<?php
print "<pre>\n";
print_r(get_defined_vars());
print "</pre>\n";
?>
------
At output i'll gets nothing :(
No any global variables.
But, at index.php I get it all.
If I move include() to global scope, all ok.
It's feature, or bug ?
--
Pavel Plesov
Simpage support
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php