How do you create optional arguments in php?

后端 未结 6 1678
耶瑟儿~
耶瑟儿~ 2020-11-27 02:54

In the PHP manual, to show the syntax for functions with optional parameters, they use brackets around each set of dependent optional parameter. For example, for the date()

6条回答
  •  无人及你
    2020-11-27 03:31

    Much like the manual, use an equals (=) sign in your definition of the parameters:

    function dosomething($var1, $var2, $var3 = 'somevalue'){
        // Rest of function here...
    }
    

提交回复
热议问题