Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1058509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:02:14+00:00 2026-05-16T18:02:14+00:00

Possible Duplicate: Is it possible to pass parameters by reference using call_user_func_array()? I have

  • 0

Possible Duplicate:
Is it possible to pass parameters by reference using call_user_func_array()?

I have the following line of code which worked in PHP 5.1, but isn’t working in PHP 5.3.

$input = array('ss','john','programmer');
call_user_func_array(array($mysqli_stmt, 'bind_param'), $input);

In PHP 5.3, I get the following warning message:

Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given in /var/www/startmission/em/class/cls.data_access_object.php on line 785

I changed the code to the following and it worked:

$a = 'johnl';
$b = 'programmer';
$mysqli_stmt->bind_param('ss',$a,$b);

I found this in the php documentation:

Care must be taken when using mysqli_stmt_bind_param() in
conjunction with call_user_func_array(). Note that
mysqli_stmt_bind_param() requires parameters to be passed by reference,
whereas call_user_func_array() can accept as a parameter a list of
variables that can represent references or values.

So my question is, how do I replicate the functionality of the call_user_func_array + bind_params such that i can dynamically bind variables at run time?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:02:15+00:00Added an answer on May 16, 2026 at 6:02 pm

    I found the answer to my problem in a user note by fabio at kidopi dot com dot br3 years ago on the PHP manual page of mysqli_stmt::bind_param() (slightly modified):

    I used to have problems with call_user_func_array and bind_param after migrating to php 5.3.

    The cause is that 5.3 requires array values as reference while 5.2 worked with real values (but also with references). So I created a secondary helper function to help me with this:

    function refValues($arr)
    { 
            $refs = array();
    
            foreach ($arr as $key => $value)
            {
                $refs[$key] = &$arr[$key]; 
            }
    
            return $refs; 
    }
    

    and changed my previous function from:

    call_user_func_array(array($this->stmt, "bind_param"), $this->values); 
    

    to:

    call_user_func_array(array($this->stmt, "bind_param"), refValues($this->values)); 
    

    This way my db functions keep working in PHP 5.2/5.3 servers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 519k
  • Answers 519k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If your entity in your database is outputting the string… May 16, 2026 at 8:26 pm
  • Editorial Team
    Editorial Team added an answer XElement provides an overload of ToString that takes an argument… May 16, 2026 at 8:26 pm
  • Editorial Team
    Editorial Team added an answer This is typical scenario for inheritance, with table-per-class-hierarchy. If you… May 16, 2026 at 8:26 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Possible Duplicate: Are there gotchas using varargs with reference parameters Hi, I have a
Possible Duplicate: Is Java pass by reference? In java are the parameters passed by
Possible Duplicate: 'pass parameter by reference' in Ruby? in this example: def test verb
Possible Duplicate: In PHP (>= 5.0), is passing by reference faster? I wonder if
Possible Duplicate: How do I pass parameters to the File::Find subroutine that processes each
Possible Duplicate: Do I have to use mysql_real_escape_string if I bind parameters? I have
Possible Duplicate: How to detect if JavaScript is disabled? I have a website which
Possible Duplicates: Pass by value vs Pass by reference performance C#.net Did anyone already
Possible Duplicate: How to serialize Dictionary<string, string> through WCF? How to pass a dictionary
Possible Duplicate: How do I zip the contents of a folder using python (version

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.