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



Share Your Thoughts

Inline Feedbacks
View all comments
Subscribe Our Channel

Email Subscription
Watch Tutorials
Copyright © 2015 - 2021 PHPEXPERTISE.COM