Learning PHP and MySQL

Example 11-13 Detecting whether a string is contained in another string

<?php
   $password
="secretpassword1";

    if  (
strstr($password,"password")){
     
echo('Passwords  cannot  contain  the  word  "password".');
  
}
else  {
   
echo  ("Password  accepted.");
  
}
?>

Example 11-13 outputs the following:

Passwords cannot contain the word “password”.

Posted by on 08/18 at 05:56 PM

Next entry: Example 11-14 Using several functions together to extract a portion of a string

Previous entry: Example 11-12 Using the word case functions

<< Back to main