Monday, April 18 2016

How to Generate Strong Password in PHP

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


I’m Blogger and Programming Blog, Tutorials, PHP, MySQL, jQuery, Laravel, Wordpress and Codeigniter