PHP Function Definition, Null Arguments

function, php

Solution

It better to define `default parameters` at the end of function declaration..

when having nullable or default parameter in the center, calling looks like:

newDate($someDay, null, $override);

however having default arguments at the end, provides a simpler function calling:

newDate($someDay, $override); // null is passed for $time

Problem

What's the best way to structure a function, that has parameters that can be null? Eg ``` function newDate($day, $time = null, $overRide) { Do something with the variables } # newDate('12', '', 'yes'); ``` Would it be to simply restructure the function as follows: ``` function newDate($day, $overRide, $time = null) { Do something with the variables } # newDate('12', 'yes'); ```

Original source