Skip to main content

PHP8 Parameters

·82 words·1 min·

In this randomly categorized post let’s cover everything parameter related in PHP81

Named arguments2
#

You can now pass arguments to a function by specifying the value name

<?php
function tralala(string $a, string $b, string $c)
{
    echo $a.' '.$b.' '.$c;
}

tralala(b: 'la', c: 'la', a: 'tra');
// tra la la

Trailing comma in parameters lists3
#

Like in es20174 trailing commas are now allowed in parameter lists

<?php

function tralala(string $a, string $b, string $c,) {}