We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39876
    • 1 Posts
    $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');
      • 28042 ☆ 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.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 13428 ☆ A M B ☆
        • 1,031 Posts
        … or add the variable to the $modx object, or use $GLOBALS …