Monday, April 18 2016
In this post we have explained about how to generate strong password in PHP. Following function is very easy to generate strong password with alphanumeric and custom special characters too.
function generate_password( $length = 8 ) { $chars = "[email protected]#$%^&*()_-=+;:,.?"; $password = substr( str_shuffle( $chars ), 0, $length ); return $password; }
parameter input is your wish default value is 8 as we mentioned see in above function.
echo generate_password(); // default echo generate_password(5); // custom parameter