0

I want to write a function that contains two more functions for example:

function connexion_stmt_bind_exe(&$stmt, $types, $var, $url){
  mysqli_stmt_bind_param($stmt, $types, $var);
  if(!mysqli_stmt_execute($stmt)){
    header($url);
    exit();
  }
}

but I have a problem when I want to insert more than one variable in $var. I use the mysqli_stmt_bind_param function a lot and I want to write one function that contains these two functions but the mysqli_stmt_bind_param function can have more than one $var, each case on its own. In some cases the function look like: mysqli_stmt_bind_param($stmt, $types, $var, $var2, $var3); And in other cases there is even more "$var" I can not use the connexion_stmt_bind_exe function because the amount of variables varies from one code to another. thanks, I would be happy for help in this matter

2
  • you can simply push $var as an ARRAY. this way you dont need to repeat yourself Commented Nov 7, 2020 at 14:06
  • Something like mysqli_stmt_bind_param($stmt, $types, ...$var); Commented Nov 7, 2020 at 14:10

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.