php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38066 Variables are not passed on to files included by classes
Submitted: 2006-07-11 14:52 UTC Modified: 2006-07-14 13:37 UTC
From: kristiankjaergaard at gmail dot com Assigned:
Status: Not a bug Package: *Programming Data Structures
PHP Version: 5.1.4 OS: Window XP
Private report: No CVE-ID: None
 [2006-07-11 14:52 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-11 14:56 UTC] 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-14 13:37 UTC] kristiankjaergaard at gmail dot com
I'm sorry to waste your time then.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Oct 14 08:01:27 2024 UTC