PHP code example of devtronic / call-user-func-assoc

1. Go to this page and download the library: Download devtronic/call-user-func-assoc library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

devtronic / call-user-func-assoc example snippets




ion sayHello($name, $age = '*not set*')
{
    echo sprintf("Hello, my name is %s and I'm %s years old", $name, $age);
}

call_user_func_assoc('sayHello', ['Julian', 23]);
// Hello, my name is Julian and I'm 23 years old

call_user_func_assoc('sayHello', [23, 'Julian']);
// Hello, my name is 23 and I'm Julian years old

call_user_func_assoc('sayHello', ['age' => 23, 'name' => 'Julian']);
// Hello, my name is Julian and I'm 23 years old

call_user_func_assoc('sayHello', ['name' => 'Julian']);
// Hello, my name is Julian and I'm *not set* years old