The Eduladder is a community of students, teachers, and programmers just interested to make you pass any exams. So we help you to solve your academic and programming questions fast.
Watch related videos of your favorite subject.
Connect with students from different parts of the world.
See Our team
Wondering how we keep quality?
Got unsolved questions?

Every-day-code-->View question

Write a PHP function that checks whether a passed string is a palindrome or not?

A palindrome is a word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run.

Here is the php fiddle
You can edit your code here :

//phpfiddle.org/lite?code=<?php\n\n\n?>\n

Taged users:

Likes:
Be first to like this question

Dislikes:
Be first to dislike this question
Here is a PHP function that checks whether a passed string is a palindrome or not:

<?php
// PHP code to check for Palindrome string in PHP
// Using strrev()

function Palindrome(\$string){

if (strrev(\$string) == \$string){

return 1;

}

else{

return 0;

}
}

// Driver Code

if(Palindrome(\$original)){

echo "Palindrome";
}

else {

echo "Not a Palindrome";
?>

Likes:

Dislikes:
Be first to dislike this answer

Watch more videos from this user Here

Learn how to upload a video over here

Palindrome Number
A palindrome number is a number which remains same when its digits are reversed.

For example, number 24142 is a palindrome number. On reversing it we?ll get the same number.

Logic:

Take a number.
Reverse the input number.
Compare the two numbers.
If equal, it means number is palindrome
Palindrome Number in PHP

<?php
function palindrome(\$n){
\$number = \$n;
\$sum = 0;
while(floor(\$number)) {
\$rem = \$number % 10;
\$sum = \$sum * 10 + \$rem;
\$number = \$number/10;
}
return \$sum;
}
\$input = 1235321;
\$num = palindrome(\$input);
if(\$input==\$num){
echo "\$input is a Palindrome number";
} else {
echo "\$input is not a Palindrome";
}
?>

Likes:
Be first to like this answer

Dislikes:
Be first to dislike this answer

Watch more videos from this user Here

Learn how to upload a video over here

solution to the code challenge

//phpfiddle.org/lite?code=<?php\nfunction Palindrome(\$string){\n if (strrev(\$string) == \$string){\n return 1;\n }\n else{\n return 0;\n }\n}\n\n\n\$original = "MALAYALAM";\nif(Palindrome(\$original)){\n echo "Palindrome";\n}\nelse {\necho "Not a Palindrome";\n}\n\n?>\n

Likes:
Be first to like this answer

Dislikes:
Be first to dislike this answer

Watch more videos from this user Here

Learn how to upload a video over here

Lets together make the web is a better place

We made eduladder by keeping the ideology of building a supermarket of all the educational material available under one roof. We are doing it with the help of individual contributors like you, interns and employees. So the resources you are looking for can be easily available and accessible also with the freedom of remix reuse and reshare our content under the terms of creative commons license with attribution required close.

You can also contribute to our vision of "Helping student to pass any exams" with these.