Jump to content

Nested Functions


epseix1

Recommended Posts

The following code:

 

$stmt->bind_param('s', $strId);
How can I define EVERYTHING within the brackets as a single function as opposed to 2 separate variables?

 

Can't seem to get syntax quite right...

 

... Is there a better method for storing all prepared statement variables, or all stmt code, in a separate "include" file using nested functions?

 

All advice greatly appreciated?

Link to comment
https://forums.phpfreaks.com/topic/277265-nested-functions/
Share on other sites

bind_param() needs a variable reference for the second argument. It's not as simple as just using an array.

 

Example:

$arr = array('');

$arr[0] .= 's';
$arr[] =& $strId;

$arr[0] .= 'i';
$arr[] =& $intFoo;

$arr[0] .= 's';
$arr[] =& $strBar;

call_user_func_array(array($stmt, 'bind_param'), $arr); // the magic happens here
call_user_func_array
Link to comment
https://forums.phpfreaks.com/topic/277265-nested-functions/#findComment-1426390
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.