title: Check password strength - Uncaught ArgumentCountError: Too few arguments to function
body: <p>How do I implement checking password strength to my PHP code?  It shows this error message:</p>
  <blockquote>
  <p>Fatal error: Uncaught ArgumentCountError: Too few arguments to function strongpass::check(), 1 passed in C:\newxampp\htdocs\fyp\index.php on line 8 and exactly 2 expected in C:\newxampp\htdocs\fyp\strongpass.php:7 Stack trace: #0 C:\newxampp\htdocs\fyp\index.php(8): strongpass-&gt;check('asdgasdfsadfasd') #1 {main} thrown in C:\newxampp\htdocs\fyp\strongpass.php on line 7</p>
  </blockquote>
  <pre><code>class strongpass{
  public function check($password,$user){
  $denum_pass = strtr($password,'5301!','seoll');
  $word_file = '/usr/share/dict/words'; // here is my dictionary
  $lc_user = strtolower($user);
  $lc_pass = strtolower($password);
  $response = &quot;OK&quot;;
  
  //password that can't be same as username or reversed username
  else if (($user == $password) || ($password == strrev($user))||
  (denum_pass == $user) || ($denum_pass == strrev($user))){
  $response = &quot; Password cannot be same with username.&quot;;}
  
  //password that doesn't contain any word in dictionary
  else if (is_readable($word_file)){
  if ($fh = fopen($word_file,'r')){
  $found = false;
  while (! ($found || feof($fh))) { 
  $word = preg_quote(trim(strtolower(fgets($fh,1024))),'/');
  if (preg_match(&quot;/$word/&quot;,$lc_pass) || preg_match(&quot;/$word/&quot;,$denum_pass)){
  $found = true;}}
  fclose($fh);
  if ($found){
  $response = 'Password is based on a dictionary word.';}}}
  return $response; } } 
  </code></pre>
  <p>The class is used like this:</p>
  <pre><code>$user = &quot;&quot;; if(isset($_POST[&quot;password&quot;])){ 
  $password = $_POST[&quot;password&quot;]; 
  include_once(&quot;strongpass.php&quot;); 
  $strongpass = new strongpass(); 
  $response = $strongpass-&gt;check($password);
  if($response != &quot;OK&quot;){ 
      $status = $response; 
  } else { 
      $status = &quot;Password is strong so parsing can continue here.&quot;; 
      
  }
  </code></pre>