• differences between session variable and global variable


    The --maximum prefix is available for mysqld only and permits a limit to be placed on how large client programs can set session system variables. To do this, use a --maximum prefix with the variable name. For example, --maximum-max_heap_table_size=32M prevents any client from making the heap table size limit larger than 32M.

    The --maximum prefix is intended for use with system variables that have a session value. If applied to a system variable that has only a global value, an error occurs. For example, with --maximum-back_log=200, the server produces this error:

     
    Maximum value of 'back_log' cannot be set

    global is just a keyword to access a variable that is declared in the top level scope and isn't available in the actual scope. This hasn't anything to do with the session: do not persist between pages.

    $a = "test";
    function useGlobalVar(){
        echo $a;   // prints nothing, $a is not availabe in this scope
        global $a;
        echo $a;   // prints "test"
    }
    

    $GLOBALS is another way to access top-level scope variables without using the global keyword:

    $a = "test";
    function useGlobalVar(){
        echo $GLOBAL['a'];   // prints "test"
    }
    

    There's a bit of of confusion between global and superglobals: Superglobals (like $GLOBALS, $_REQUEST, $_SERVER) are available in any scope without you having to make a global declaration. Again, they do not persist between pages (with the exception of $_SESSION).

    $_SESSION is a Superglobal array that persist across different pages.

  • 相关阅读:
    awk
    Python自动化开发之python的常用模块
    sed
    python自动化开发-8
    正则表达式-2-正则表达式实战1
    linux之sort和uniq
    SSH免密登录
    Docker下安装Mongodb
    Docker下安装Elasticsearch
    Docker下安装RabbitMQ
  • 原文地址:https://www.cnblogs.com/CreatorKou/p/9037728.html
Copyright © 2020-2023  润新知