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: [EMAIL PROTECTED]
 

-----Original Message-----
From: Pavel Plesov [mailto:[EMAIL PROTECTED]] 
Sent: Thursday March 14, 2002 7:56 AM
To: [EMAIL PROTECTED]
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



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to