palindrome code in php
METHOD1:
<?php
//madam aibohphobia Malayalam
$word=”Malayalam”;
$word=strtoupper($word);
$len=strlen($word);
$first=substr($word,0,($len/2));
$word=strrev($word);
$second=substr($word,0,($len/2));
if($first==$second)
{
echo “Palindrome”;
}
else
{
echo “Not Palindrome”;
}
?>
METHOD2:
<?php
//madam aibohphobia Malayalam
$word=”Malayalam”;
$word=strtoupper($word);
$first=$word;
$second=strrev($word);
if($first==$second)
{
echo “Palindrome”;
}
else
{
echo “Not Palindrome”;
}
?>