Re: include file in a class with global/parent scope?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I've cleaned up my question a bit.

I want the included file which is called within a method of a class to
have the same scope as the instantiation of the class's object.  That
is, i want a class to include a file in the calling object's scope.  How
would one do this?

'test.php'
<?php
class CSomeClass {
 public function cinclude() {
   include('vars.php');
 }
}

$object = new CSomeClass;
$object->cinclude();
echo $vars;//i want this to print 'hi'
include('vars.php');
echo "obvious $vars";
?>

'vars.php'
<?php
$vars = "hi";
?>

OUTPUT:
Notice: Undefined variable: vars in ...\test.php on line 10
obvious hi

DESIRED OUTPUT:
hi
obvious hi

Thanks,
dK

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux