Page 1 of 1

the declaration of global variables

Posted: Tue Apr 13, 2004 1:42 am
by victor
does anyone knows if I set global register to off in the php.ini will declaring a variable as global in a function still take effect?

<?php
function get($var){
return $var;
}

function set($var, $val){
global $var;
$var = $val;
}
?>

If i use the function in another file say try.php

set($donkey, 5);

echo ($donkey); (does not seems to print out... cos no value :cry: )

any kind soul out there pls help..

Posted: Tue Apr 13, 2004 1:57 am
by victor
btw, should be echo get($donkey).

Posted: Tue Apr 13, 2004 2:05 am
by victor
it is settled, just add global into get function also..

:oops: