Difference between strpos and stripos in php


strpos()Function in PHP:


strpos():Returns the position of the first occurrence of a substring in a string.
If the string is not found, this function returns FALSE.

Strpos Syntax:
strpos(string,search,start)

Strpos() function example in php:
<?php
$phpString = 'strpos function in php';
$search   = 'function';
$position = strpos($phpString, $search);


if ($position !== false)
{
     echo "Found at position $position";
}
 else
{
     echo "Not Found";
}
?>

stripos() Function in PHP:


The stripos() function is case-insensitive.
stripos():Returns the position of the first occurrence of a case-insensitive substring in a string.
If the string is not found, this function returns FALSE.

stripos Syntax:
stripos(string,search,start)

stripos () function example in php:
<?php
$phpString = 'strpos function in php';
$search   = 'Function';
$position = stripos($phpString, $search);


if ($position !== false)
{
     echo "Found at position $position";
}
 else
{
     echo "Not Found";
}
?>

Difference between strpos and stripos in php:
  1. stripos works in php5, strpos in php4 and php5.
  2. Unlike the strpos(), stripos() is case-insensitive.