Search
 
SCRIPT & CODE EXAMPLE
 

PHP

vriadic function in php

<?php

function sum(...$numbers)
{
    $total = 0;
    for ($i = 0; $i < count($numbers); $i++) {
        $total += $numbers[$i];
    }

    return $total;
}
echo sum(10, 20) . '<br>'; // 30
echo sum(10, 20, 30) . '<br>'; // 60
Code language: PHP (php)
Comment

vriadic function in php

<?php

function sum(int ...$numbers): int
{
    $total = 0;
    for ($i = 0; $i < count($numbers); $i++) {
        $total += $numbers[$i];
    }

    return $total;
}
Code language: PHP (php)
Comment

vriadic function in php

<?php

function sum(int ...$numbers): int
{
    return array_sum($numbers);
}
Code language: PHP (php)
Comment

PREVIOUS NEXT
Code Example
Php :: woocommerce_continue_shopping_redirect 
Php :: get row ezSql | select on ezSql 
Php :: Donut chart in PHP 
Php :: config in php 
Php :: wordpress function _() not working 
Php :: php prepared statement and conditional 
Php :: laravel api get controller 
Php :: php print keys of array 
Php :: gan_sql 
Php :: php 7.1 functions parameters with "?" 
Php :: Laravel display the date the participation was created 
Php :: PHP OOP - Traits 
Php :: php artisan reset --force 
Php :: pass variable in translation larvel 
Php :: utf8 decode 
Php :: php cors error 
Php :: spatie sluggable not working 
Php :: display PHP errors based on environment variable 
Php :: File: C:xampphtdocsmarvellogistikapplicationlibrariesProfiler.php Line: 386 Function: sendDataInHeaders 
Php :: shopware php get cookie 
Php :: show all tags 
Php :: how to get create table query preview in phpmyadmin 
Php :: PHP 7 PDF page group - sizeof(): Parameter must be an array or an object that implements Countable 
Php :: cmb2-repeater video show single page with wordpress 
Php :: nested attributes - PHP 8.1 
Php :: small rce php 
Php :: Eagar loading,parent child relationship,Sub relationship in laravel 
Php :: PHP Validate POST value emoty & Set 
Php :: laravel passport login with username 
Php :: twiml gather php 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =