PHP/String/stristr

Материал из Web эксперт
Перейти к: навигация, поиск

Detecting whether a string is contained in another string

   <source lang="html4strict">

<?php $password="secretpassword1"; if (strstr($password,"password")){

   echo("Passwords cannot contain the word "password".");

} else {

   echo ("Password accepted.");

} ?>

 </source>
   
  


Using Substring Alternatives

   <source lang="html4strict">

//string strstr ( string haystack, string needle ) //string stristr ( string haystack, string needle ) <?php $url = "www.wbex.ru"; $domain = strstr ($url, "."); echo $domain; ?>

 </source>