PHP 8.2.20 Released!

Voting

: one minus zero?
(Example: nine)

The Note You're Voting On

tongcheong77 at gmail dot com
6 years ago
If you are using PHP 7 and func_num_args is in your base class which you extended, you can pass your arguments with the 'spat' operator.

class Sql {

public function doGetWhere(...$args) {

$num_args = func_num_args();
$args_list = func_get_args();

echo '<pre>';
var_dump($args_list);
echo '<pre>';
}
}

class Member extends Sql {

public function getWhere(...$args) {

$this->doGetWhere(...$args);

}
}

$member = new Member();
$member->getWhere('first_name','last_name','userlevel','email','where','email','=',$sub_email);

However, take note that if you 'new up' the 'Sql' class in your 'Member' class above, instead of extending it, you will not need to pass your arguments as a variable. Just my two cents. -Bruce tong

<< Back to user notes page

To Top