Reputation: 786
I am getting this error on line 57: $password = str_replace($key, $value, $password, 1);
As far as I can tell, I am only passing in variables. Here is some more context:
$replace_count = 0;
foreach($replacables as $key => $value)
{
if($replace_count >= 2)
break;
if(strpos($password, $key) !== false)
{
$password = str_replace($key, $value, $password, 1);
$replace_count++;
}
}
Upvotes: 18
Views: 44080
Reputation: 122429
Passing 1
there makes no sense. (Why not pass 42
, or -5
?) The 4th parameter of str_replace
is only used to pass information back to you. The function does not use the original value of the variable at all. So what would be the point (even if allowed) of passing something in, if it is not used, and you are not going to use the new value sent back to you? That parameter is optional; just don't pass anything at all.
Upvotes: 11
Reputation: 2118
You can't pass a constant of 1, a fix is to set it to a variable as so.
Change:
$password = str_replace($key, $value, $password, 1);
to:
$var = 1
$password = str_replace($key, $value, $password, $var);
UPDATE: Changed to declare variable outside of the method call from feedback in comments.
Upvotes: 13