Difference between strpos and stripos in php
Posted by Raj
Difference between strpos and stripos 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";
}
?>
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:
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:
- stripos works in php5, strpos in php4 and php5.
- Unlike the strpos(), stripos() is case-insensitive.
This entry was posted on October 4, 2009 at 12:14 pm, and is filed under
difference between,
PHP,
PHP interview questions and answers,
stripos,
stripos() function in php,
strpos,
strpos() function in php
.You can leave a response, or trackback from your own site.