Questions tagged [call-user-func-array]
21 questions
5
votes
4 answers
When to use call_user_func_array
I've read other answers on stack pertaining to using call_user_func_array vs just calling the function but I still can't glean when the former should be used. I get that you might want to use call_user_func_array when you don't know how many args…

Alex
- 9,215
- 8
- 39
- 82
3
votes
1 answer
Passing a class, method and arguments to WordPress functions
When adding pages to the WordPress admin you use add_menu_page, which accepts a callable function/method.
class Foo
{
public function __construct()
{
add_menu_page($page_title, $menu_title, $capability, $menu_slug, [$this, 'bar'],…

no.
- 2,356
- 3
- 27
- 42
2
votes
0 answers
PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback
This is error:
PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'App\Bootstrap' does not have a method 'monsterinsights_vue_get_notifications' in /home2/*****/public_html/wp-includes/class-wp-hook.php on line…

sp33d
- 31
- 1
- 4
2
votes
2 answers
Check if call_user_func_array was executed succesfully
A function or method can be called dynamically using call_user_func_array. If the call itself fails, FALSE is returned. Also, call_user_func_array returns the return values from the function or method that is called.
So when the called function or…

Code4R7
- 2,600
- 1
- 19
- 42
2
votes
2 answers
Return an array from mysqli stmt query
I'm trying to convert a site to use prepared mysql statements, however I'm having some trouble replacing my use of fetch_array().
The comments on php.net offer a solution which I would have thought should work but for some reason I'm getting strange…

Rob
- 23
- 1
- 3
1
vote
1 answer
call_user_func_array("shell_exec", ...) not working in php
In php, when I call
shell_exec('ls');
it executes the commands 'ls' in shell and returns a string which consists of set of files in the directory
But when I call
call_user_func_array('shell_exec', 'ls');
it is always returning false. What…

satya
- 469
- 1
- 6
- 14
1
vote
1 answer
call_user_func_array "doesn't work" with bind_param when passing array already in variable
i'm having trouble using call_user_func_array in this code
$stmt=$mysqli->prepare($query);
$txt=array('ii',1,1);
call_user_func_array(array($stmt,"bind_param"),$txt);
$stmt->execute();
$result=$stmt->get_result();
while ($row =…

Luciano
- 55
- 6
1
vote
1 answer
PHP 5.5, can't get call_user_func_array to work with bing_param
I have PHP version 5.5.9-1 and having trouble with call_user_func_array and bind_param for stmt. I have the following code
$query = "SELECT * FROM studentTable WHERE firstname = ?";
if(!($stmt = $conn->prepare($query))){
echo "Prepare failed: ("…

DanielJ
- 245
- 1
- 2
- 10
0
votes
1 answer
How to write a specific model method as the callback in call_user_func_array()?
I'm been trying to send a dynamic number of arguments to a function in Codeigniter and have been running into a wall with call_user_func_array.
One error I'm getting "Undefined property: Account::$callShowMessage" is making me wonder if it's even…

jsuissa
- 1,754
- 6
- 30
- 64
0
votes
1 answer
Undefined property: mysqli_stmt::$bind_param
I want to bind variable number parameters using call_user_func_array in this way(please read comments at the code):
function dbQuery()
{
global $dbconnection;
if (func_num_args() < 1 || func_num_args() === 2) {
return error('خطای…

mwxgaf
- 66
- 1
- 9
0
votes
2 answers
call_user_func_array and __call create infinite loop
I have a class A and class B which inherits from class A, and I want to run some checks before I run the function.
class A {
public class __call($name, $params) {
if (method_exists?($this, $name)) {
$result =…

sad_jane
- 23
- 2
0
votes
0 answers
Too few arguments after passage to php7.1. 3 arguments passed and 4 arguments expected. Script to create images on the fly
Message error: 3 passed and at least 4 expected.
I understand that 7.1 creates a fatal error but I don't understand why it is expecting 4 arguments in this case and it says that it passed 3 arguments instead of the two normally accepted with…

Rich
- 107
- 1
- 13
0
votes
1 answer
How to call_user_func_array on an object that has been set to a variable?
If I assigned an object to the model instance variable, how would I use call_user_func_array on it?
use App\Repositories\BaseRepositoryDynamic as BR;
$repo = new BR();
$repo->model=new User();
$repo->first();
class BaseRepositoryDynamic
…

Dr. Chocolate
- 2,043
- 4
- 25
- 45
0
votes
1 answer
Can someone explain how call_user_func_array(array(arg1, arg2), []) works?
I know this is a really vague question, but I just don't intuitively get it. I'm mostly a javascript/java guy, so you'll have to excuse me.
What happens inside of that first array call when doing something like:
call_user_func_array(array($this,…

webhound
- 339
- 1
- 4
- 13
0
votes
2 answers
How to bind varying number of inputs when some are blob and must be sent send_long_data() in PHP
I am working on a school assignment and I need to process a form with values such as location, price, description, and a 1 to 4 images up to 5MB each. I need to upload to a database, but I cannot get the images sent using send_long_data(). I do not…

Al T
- 23
- 3