How to create a random password in PHP

I am trying to generate a random password in php.

If you ever have the need to create a random password or username you can use something like this.