PHP Syntax Error in Setting Global Variable

前端 未结 4 2181
野性不改
野性不改 2020-12-20 19:17

Ok, so my PHP is, to say the least, horrible. I inherited an application and am having to fix errors in it from someone that wrote it over 7 years ago. When I run the page

4条回答
  •  感动是毒
    2020-12-20 20:13

    The global keyword is used inside of functions to declare that they will use a globally defined variable, not to define one. Just remove the word global, and if you need those values in functions, add:

    global $a;
    

    ...to the start to the function.

提交回复
热议问题