Home » Php » php – $GLOBALS null in include

php – $GLOBALS null in include

Posted by: admin February 25, 2020 Leave a comment

Questions:
function instant_info($item_name)
{
    global $_LANG, $woExpire_on, $wo_domain;
    $GLOBALS['item_name'] = $item_name;
    $GLOBALS['wo_domain'] = $wo_domain;
    $GLOBALS['woExpire_on'] = $woExpire_on;
    $a = dir("content/addons/");
    while (false !== ($entry = $a->read()))
    {
        if (is_dir('content/addons/'.$entry) && $entry != '.' && $entry != '..') {
            if (file_exists("content/addons/".$entry."/functions/instant_info.php")) {
                include_once("content/addons/".$entry."/functions/instant_info.php");
            }
        }

    }
    $a->close();
    if(empty($GLOBALS['info'])) { $GLOBALS['info'] = 'None'; }
    return $GLOBALS['info'];
}

When i use echo instant_info('test_info') i don’t get any output, i made a test and on included file all variables are empty on instant_info('test_info') function, but i use $GLOBALS, why these variables are not passed to included file? (in included file i set $GLOBALS['info'])

How to&Answers: