Do variables passed to bindParam need to be initialized?
EDIT: REAL USE CASE
$user = 0; //IS THIS REQUIRED?
$stmt = $db->prepare("SELECT * FROM Blah WHERE something=?");
$stmt->bindParam(0, $user);
foreach($array as $user)
$stmt->execute();
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
It depends on what kind of param you bind. If it’s an out parameter you don’t need to initialize it. If it’s an in or inout parameter you need to initialize it for obvious reasons.
In your case you should really initialize it since you are using it in the
WHEREpart, i.e. as an in parameter.From the docs: