#38066 [Bgs]: Variables are not passed on to files included by classes

From: Date: Fri, 14 Jul 2006 13:37:38 +0000
Subject: #38066 [Bgs]: Variables are not passed on to files included by classes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-99447@lists.php.net to get a copy of this message
 ID:               38066
 User updated by:  kristiankjaergaard at gmail dot com
 Reported By:      kristiankjaergaard at gmail dot com
 Status:           Bogus
 Bug Type:         *Programming Data Structures
 Operating System: Window XP
 PHP Version:      5.1.4
 New Comment:

I'm sorry to waste your time then.


Previous Comments:
------------------------------------------------------------------------

[2006-07-11 14:56:56] tony2001@php.net

Only local function scope is passed to the included file when it's
included from a function.
This is expected.

------------------------------------------------------------------------

[2006-07-11 14:52:23] kristiankjaergaard at gmail dot com

Description:
------------
When files are included from within classes, variables are not passed
on to the included files.

Reproduce code:
---------------
a.php:
<?php

class Factory
{
    static function doinclude() {
        include_once('b.php');
    }
}

$var = "I've found a bug";
var_dump($var);

Factory::doinclude();

?>

b.php:
<?php

var_dump($var);

?>

Expected result:
----------------
string(16) "I've found a bug" string(16) "I've found a bug"

Actual result:
--------------
string(16) "I've found a bug" NULL


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=38066&edit=1


Thread (3 messages)

« previous php.bugs (#99447) next »