Does PHP have “named parameters” so that early arguments can be omitted and later arguments can be written? [duplicate]

Use arrays :

function test($options = array()) {
    $defaults = array(
        't1' => 'test1',
        't2' => 'test2',
        't3' => 'test3',
    );
    $options = array_merge($defauts, $options);
    extract($options);
    echo "$t1, $t2, $t3";
}

Call your function this way :

test(array('t3' => 'hi, i am different'));

Leave a Comment