php global variables in drupal
helavissa - July 2, 2009 - 20:38
Hello,
I have a question (hopefully easy one) - how do I access a php global variable inside a function in Drupal?
For example, following code prints "Hello World", but why in Drupal it doesn't work?
<?php
$test = "Hello World";
function printVar(){
global $test;
echo $test;
}
printVar();
?>Please help,
Thank you

that's not a drupal prob :P
try this
global $test;
$test = "hello world";
function printVar(){
//print $GLOBALS['test'];
global $test;
echo $test;
}
printVar();
that works! Thank you
that works! Thank you