I'm debugging some older PHP code. The original programmer included an operation which I think is intended to generate a random id string, by adding two random integers to a string and passing it to the md5() method, which seems to break the program:
$id = md5($someString + rand(0, 9999999) + rand(0, 9999999));
Passing each part of the argument to the method separately works as expected:
$id = md5($someString); // Works fine
$id = md5(rand(0, 9999999)); // Works fine
Joining the arguments together as a string before passing it also works:
$randomInt_0 = rand(0, 9999999);
$randomInt_1 = rand(0, 9999999);
$id = md5($someString . $randomInt_0 . $randomInt_1); // Works fine
Why is the original code not working (I assume it did at some point)?
Might passing a string + integer addition to md5() cause a problem?
.not the+Just like you used in the lines that work :)0 + rand + rand.