echo $GLOBALS['g_' . 'aaa'];

 

 

/**
 * force config variable from a global to avoid recursion
 *
 * @param string $p_option  Configuration option to retrieve.
 * @param string $p_default Default value if not set.
 * @return string
 */
function config_get_global( $p_option, $p_default = null ) {
    global $g_cache_config_eval;
    if( isset( $GLOBALS['g_' . $p_option] ) ) {
        if( !isset( $g_cache_config_eval['g_' . $p_option] ) ) {
            $t_value = config_eval( $GLOBALS['g_' . $p_option], true );
            $g_cache_config_eval['g_' . $p_option] = $t_value;
        } else {
            $t_value = $g_cache_config_eval['g_' . $p_option];
        }
        return $t_value;
    } else {
        # unless we were allowing for the option not to exist by passing
        #  a default, trigger a WARNING
        if( null === $p_default ) {
            error_parameters( $p_option );
            trigger_error( ERROR_CONFIG_OPT_NOT_FOUND, WARNING );
        }
        return $p_default;
    }
}
<?php
$g_aaa=123;
$g_bbb=456;

function test(){
    echo $GLOBALS['g_' . 'aaa'];
    echo $GLOBALS['g_' . 'bbb'];
}

test();

//123456

 

posted @ 2018-03-19 15:38  sky20080101  阅读(104)  评论(0)    收藏  举报