Named Arguments in PHP

前端 未结 3 1278
自闭症患者
自闭症患者 2020-12-12 05:09

In C#, there is a new feature coming with 4.0 called Named Arguments and get along well with Optional Parameters.

private static void writeSomething(int a =          


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-12 05:27

    You can get around that by having an array such as $array= array('arg1'=>'value1'); And then let the function accept the array such as function dostuff($stuff); Then, you can check arguments using if(isset($stuff['arg1')){//do something.} inside the function itself

    It's just a work-around but maybe it could help

提交回复
热议问题