|
Posted by Rik Wasmus on 09/30/07 13:01
On Sat, 29 Sep 2007 19:27:28 +0200, howa <howachen@gmail.com> wrote:
> On 9 29 , 9 49 , Bruno Barros <rage...@gmail.com> wrote:
>> On 29 Sep, 13:23, howa <howac...@gmail.com> wrote:
>> > I have a function, e.g.
>>
>> > function foo() {
>> > include("bar.php");
>>
>> > }
>>
>> > and the bar.php contain contents e.g.
>>
>> > $global_v1 =3D "abc";
>> > $global_v2 =3D "def";
>>
>> > I want to execute function foo(), but at the same time, let the
>> > variables declared in bar.php to have global scopem is it possible?=
>> function foo() {
>> global $global_v1;
>> global $global_v2;
>>
>> include "bar.php";
>>
>> }
> Assume that I know nothing about the stuffs inside bar.php...is it
> possible?
function foo(){
include_once('bar.php');
foreach(get_defined_vars() as $name =3D> $value){
if(!in_array($name, =
array('_GET','_POST','GLOBALS','_COOKIE','_SESSION','_ENV','_FILES','_RE=
QUEST','_SERVER')))
$GLOBALS[$name] =3D $value;
}
}
It's really kinda ugly though.
-- =
Rik Wasmus
[Back to original message]
|