PHP: Global variable scope

前端 未结 5 542
天命终不由人
天命终不由人 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:04

    Is there a reason why you can't pass the variable into your function?

    myFunction($myVariable)
    {
      //DO SOMETHING
    }
    

    It's a far better idea to pass variables rather than use globals.

提交回复
热议问题