$ourVar = 'test';
function ourFunc ($param) {
global $ourVar, $modx;
print_r ( $modx ); // normal big output of $modx object
print_r ( $param ); // "paramparam"
print_r ($ourVar); // "" <----- Why?!
}
ourFunc('paramparam');
-
☆ A M B ☆
- 24,524 Posts
Snippets are processed through the PHP eval() function. That can have odd effects on scope. Perhaps you would do better by passing the variable as a parameter to your function.
-
☆ A M B ☆
- 1,031 Posts
… or add the variable to the $modx object, or use $GLOBALS …