Problems accessing variables with the global keyword - Joomla! Forum - community, help and support


hi,

i have problems accessing variables within function. variable defined in same file function is, when call function (happens in file) cant use variable.

file function.php
<?php

$var = "hello";

function test()
{
global $var;
var_dump($var);
}
?>

file caller.php
<?php

include "function.php";

test(); // prints null

?>

is me can't working?

your example works fine, producing following line:

code: select all

string(5) "hello"





Comments

Popular posts from this blog

Joomla site hacked, cant see front and - Joomla! Forum - community, help and support

Christian Home School Programs - Joomla! Forum - community, help and support

Trouble with PF_OutFlag_I_USE_AUDIO and PF_CHECKOUT_LAYER_AUDIO