How to avoid call-time pass-by-reference deprecated error in PHP?

后端 未结 5 694
情话喂你
情话喂你 2020-12-14 16:07

I\'m trying to reduce the warnings that are sent to my apache server log.

One warning is:

Call-time pass-by-reference has bee

5条回答
  •  無奈伤痛
    2020-12-14 16:19

    like noted above in a previous answer, the issue is at CALL time, not definition time.. so you could define a function as:

    function foo(&$var1,$var2,$var3=null){
        // procesing here
    }
    

    then call as:

    $return = foo($invar1,$invar2);
    

    your first invar is passed by reference, second one is not.

    the error appears when you try to call like so:

    $return = foo(&$invar1,$invar2);
    

提交回复
热议问题