David Sklar addressed the question of when to use call_user_func_array in his PHP Cookbook. So, to focus on one comment of the OP:
"...don't you always need to know the arguments if they are to be used
in a function?"
Here's an instance where call_user_func() can come in handy:
<?php
function Test(){
$args = func_get_args();
call_user_func_array("printf",$args);
}
Test("Candidates 2014: %s %s %s %s\n","Tom","Debbie","Harry", "Sally");
Test("Candidates 2015: %s %s\n","Bob","Sam","Sarah");
See live code
With the pair of call_user_func_array() and func_get_args(), the user-defined function Test() can take a variable number of arguments.
Also, useful for aggregating methods (see PHP Cookbook p208-210) as the following simplified example demonstrates:
<?php
class Address {
protected $city;
public function getCity() {
return $this->city;
}
public function setCity($city) {
$this->city=$city;
}
}
class Person {
protected $name="Tester";
protected $address;
public function __construct() {
$this->address = new Address;
}
public function getName(){
return $this->name;
}
public function __call($method, $args){
if (method_exists($this->address,$method)) {
return call_user_func_array( array($this->address,$method),$args);
}
}
}
$sharbear = new Person;
echo $sharbear->setCity("Baltimore");
echo "Name: ",$sharbear->getName(),"\n";
echo "City: ",$sharbear->getCity();
See live code
Addendum
Since PHP 5.6, PHP supports variadic functions and argument unpacking, so call_user_func() and func_get_args() may be replaced with respect to variable arguments as follows:
<?php
function Test(...$args){
printf(...$args);
}
$namesT = ["Timmy","Teddy","Theo","Tad"];
$namesB = ["Bobby","Bill","Brad"];
Test("T Names: %s %s %s %s\n",...$namesT);
Test("B Names: %s %s %s\n",...$namesB);
See live code