Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

Palindrome Program in PHP

Palindrome Program in PHP

<?php
	   $original = 1001; 
	   $number=$original;
    $temp = $number;   
    $new = 0;   
    while (floor($temp)) {   
        $d = $temp % 10;   
        $new = $new * 10 + $d;   
        $temp = $temp/10;   
    }   
    if ($new == $number){   
         echo "Palindrome". $original;
		}
		else{ 
        echo "Not a Palindrome".$original; 
    }            
?>

Output

Palindrome1001

Palindrome Program in PHP with form values entered by the user

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</hea  d>
<body>

<form  method="POST"> 

Enter Number: <input type="text" name="1"><br>


<input type="submit"value="Check Number" name="submit">

</form>





<?php
if (isset($_POST['submit'])){
$units=$_POST['1'];
	   $original = 1001; 
	   $number=$original;
    $temp = $number;   
    $new = 0;   
    while (floor($temp)) {   
        $d = $temp % 10;   
        $new = $new * 10 + $d;   
        $temp = $temp/10;   
    }   
    if ($new == $number){   
         echo "Palindrome". $original;
		}
		else{ 
        echo "Not a Palindrome".$original; 
    }               }
?>


</body>
</html>

Output

Palindrome Program in PHP

Figure: Palindrome Program in PHP

Topic Covered

Palindrome Program in PHP.

Fazal Rehman Shamil Click Here to Know More
Instructor, Researcher, Blogger, SEO Expert, Poet and Publisher of International Journal Of Software, Technology & Science ISSN : 2616 - 5325
Dear Professors and Resarchers!You are welome to Cite these tutorials in your research or slides etc. Please don't forget to mention the reference of website. Copy Paste of text is strcitly forbidden. Images can be reuse because images are protected with watermark.