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

后端 未结 5 715
情话喂你
情话喂你 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:32

    You could pass in the array, let it manipulate it, and then "return" it, instead of messing with the original reference. It shouldn't be too hard to just include a return and assignment.

    public function takeScriptsWithMarker($lines, $marker) {
        //...
        return $lines;
    }
    

    Usage:

    $lines = takeScriptsWithMarker($lines, $marker);
    

提交回复
热议问题