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.

generate_strong_password_in_php

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

 

 

Comments

comments

phpexpertise

Iā€™m Blogger and Programming Blog, Tutorials, PHP, MySQL, jQuery, Laravel, Wordpress and Codeigniter