PHP WEB DEVELOPMENT PART - 3 PROBABLE MOST IMPORTANT INTERVIEW QUESTIONS AND ANSWERS MADE BY ME GENERALLY ASKED IN PITANGENT ANALYTICS AND TECHNOLOGY SOLUTIONS PVT. LTD. FOR FRESHERS
PHP WEB DEVELOPMENT PART - 3 PROBABLE MOST IMPORTANT INTERVIEW QUESTIONS AND ANSWERS MADE BY ME GENERALLY ASKED IN PITANGENT ANALYTICS AND TECHNOLOGY SOLUTIONS PVT. LTD. FOR FRESHERS
Q13. Write a program to check if a string is a palindrome.
Ans:
<?php
$str="noon";
$str=strtolower($str);
$str2=strtolower(strrev($str));
if($str==$str2){
echo "The string $str is a palindrome";
}
else{
echo "The string $str is not a palindrome";
}
?>
Output =>
Q2. How to find duplicate rows in a table?
Ans: To find duplicate rows in a table I need to use GROUP BY and HAVING clauses.
SELECT column1, column2,..., COUNT(*)
FROM table_name
GROUP BY column1,column2,...
HAVING COUNT(*) > 1;
Q3. Write a program to count the number of vowels in a string.
Ans:
<?php
$str="I love playing cricket";
$vow=0;
$str=str_replace(" ","",$str);
$length=strlen($str);
for($i=0;$i<$length;$i++){
if($str[$i] == "A" || $str[$i] == "E" || $str[$i] == "I" || $str[$i] == "O" || $str[$i] == "U" || $str[$i] == "a" || $str[$i] == "e" || $str[$i] == "i" || $str[$i] == "o" || $str[$i] == "u"){
$vow++;
}
}
print_r("The number of vowels in a string is: ".$vow);
?>
Output =>
Comments
Post a Comment