views:

362

answers:

1

When I include a PHP script via Jumi, it seems to break the global keyword. Example:

<?php

$a = 5;

function foo()
{
        global $a;
        if (isset($a))
                echo $a;
        else
                echo '$a is not set';
}

foo();

?>

When I run this PHP script (named test.php) by itself, it correctly prints 5. When I run it included via Jumi in a Joomla article solely containing this:

{jumi test.php}{/jumi}

It prints $a is not set.

Is this a bug in Jumi or Joomla, or is there some (un)documented way I'm supposed to work around it?

When I include a PHP script via Jumi, it seems to break the global keyword. Example:

<?php

$a = 5;

function foo()
{
        global $a;
        if (isset($a))
                echo $a;
        else
                echo '$a is not set';
}

foo();

?>

When I run this PHP script (named test.php) by itself, it correctly prints 5. When I run it included via Jumi in a Joomla article solely containing this:

{jumi test.php}{/jumi}

It prints $a is not set.

Is this a bug in Jumi or Joomla, or is there some (un)documented way I'm supposed to work around it?


UPDATE: If I mark $a as global in the top scope of the script:

<?php

global $a;
$a = 5;
function foo()
{
        global $a;
        if (isset($a))
                echo $a;
        else
                echo '$a is not set';
}
foo();

?>

test.php works properly both run by itself and included via Jumi. My best guess is that Jumi scripts are included in function context, not global context.

+1  A: 

Your global-at-the-top solution doesn't work for me (J1.5 / jumi 1.2.0) :(

R-U-Bn
Are you marking it global on both the inside and outside?
Joey Adams