help with passing arguments to function

前端 未结 6 1113
慢半拍i
慢半拍i 2020-12-06 23:49
function get_tags_by_criteria($gender=\"%\", $min_age_of_birth=\"%\", $max_age_of_birth=\"%\", $country=\"%\", $region=\"%\", $city=\"%\", $tag=\"\") {
6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-07 00:41

    Unfortunately you can't do this - unspecified optional arguments always have to be at the tail end of a function argument list. Instead, what you can do is use NULL for the arguments you don't wish to specify and then have your function check to see if an argument is NULL and assign it the default value instead.

提交回复
热议问题