Why am I getting an “Undefined variable” notice in PHP?

后端 未结 2 1013
借酒劲吻你
借酒劲吻你 2021-01-22 19:24

So I have the following:




Name:
2条回答
  •  日久生厌
    2021-01-22 20:07

    You need to set the variable to be global for that to work.

    At the start of the show_form method, add this code:

    global $defaults;
    

    Or, a better solution as pointed out already is to return the variable and use $defaults = show_form().

提交回复
热议问题