PHP: Global variable scope

前端 未结 5 536
天命终不由人
天命终不由人 2020-12-22 12:26

I have a separate file where I include variables with thier set value. How can I make these variables global?

Ex. I have the value $myval in the v

5条回答
  •  佛祖请我去吃肉
    2020-12-22 13:07

    Same as if you declared the variable in the same file.

    function doSomething($arg1, $arg2) {
        global $var1, $var2;
        // do stuff here
    }
    

提交回复
热议问题