PHP Built-in Functions


There are two kinds of PHP functions: (i) built-in functions and (ii) user-defined functions. There are more than 700 PHP built-in functions available, e.g.,
The following program returns the number of keywords matched between a string and a query by using the built-in functions:
  • stripos(string,find), which returns the position of the first occurrence of a keyword inside the string case-insensitively. If not found, returns the Boolean value false, which may or may not be equal to the value 0.

  • is_numeric( variable ), which finds whether a variable is a number. It is used because the function stripos may return a position 0, which is not equal to the value false.
 <html><body>
  <?php
   $str   = "";
   $query = "";
   $sep   = "";
   $word  = strtok( $query, $sep );
   $match = 0;
   while ( $word != false ) {
    if ( is_numeric(stripos($str, trim($word))) )
     $match++;
    $word = strtok( $sep );
   }
   echo $match;
  ?>
 </body></html>
Output =      




      “When someone loves you, the way they talk about you is different.    
      You feel safe and comfortable.”    
      ― Jess C. Scott, The Intern