How to create a random password at any length.|
TAGS: Random, Password, PHP
When you have users signing up to your website, you often want to generate a password for them. There are of course different ways to do this. I give you one here that works for me.
We make a function containing the code. In this example the function is called straight away, so you see the result instantly. But we can call it where we need it in our program, and get a password in return.
Now $MyPass holds the password just created, and can be used in the code.
I have removed I, l, L, i, o, O, 0, 1 from the list of numbers, and characters in the alphabet, to avoid mistakes.
Try to change the value from 6 into some other value giving the length of the password.