epseix1 Posted April 24, 2013 Share Posted April 24, 2013 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 More sharing options...
requinix Posted April 24, 2013 Share Posted April 24, 2013 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.