PHP function missing argument error

前端 未结 5 450
孤街浪徒
孤街浪徒 2020-12-19 06:02

My validate function looks like that

function validate($data, $data2 = 0, $type)
{
...

Function call example

if ($result =          


        
5条回答
  •  甜味超标
    2020-12-19 06:22

    Missing argument 3 ($type) for validate()

    Always list optional arguments as the last arguments. Since PHP doesn't have named parameters nor "overloading ala Java", that's the only way:

    function validate($data, $type, $data2 = 0) {
    }
    

提交回复
热议问题