A very simple program that I wrote that will ask the user to give a number and then our program will check if the given number is a Palindrome or Not a Palindrome using PHP as our programming language.
I am currently accepting programming and web development work kindly contact me in the following email address for further details. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.
Sample Program Output
Program Listing
palindrome.php
<!-- palindrome.php -->
<!-- Written By Mr. Jake R. Pomperada, MAED-IT -->
<!-- January 25, 2018 Thursday Papa Jun's Birthday -->
<!-- jakerpomperada@yahoo.com and jakerpomperada@gmail.com -->
<!-- Bacolod City, Negros Occidental Philippines -->
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<style>
.art {
font-family: arial;
font-weight: bold;
color:red;
text-align: center;
width:45%;
background-color:yellow;
}
.art2 {
font-family: arial;
font-weight: bold;
font-size: 25px;
color:blue;
text-align: center;
width:45%;
background-color:lightgreen;
}
body {
font-family: arial;
font-weight: bold;
font-size: 20px;
}
input[type=submit] {
background-color: #008CBA;
font-family: arial;
font-weight: bold;
font-size: 20px;
height: 50px;
width: 120px
text-align: center;
cursor: pointer;
}
input[type=text] {
font-family: arial;
font-weight: bold;
font-size: 20px;
}
</style>
<body>
<?php
error_reporting(0);
?>
<h1 class="art"> Palindrome Number in PHP </h1>
<p class="art2"> Created By Mr. Jake R. Pomperada, MAED-IT </p>
<br><br>
<form method="post">
Give a Number :
<input type="text" name="val_num" autofocus=""><br><br>
<input type="submit" name="submit" value="Check">
<input type="submit" name="clear" value="Clear">
</form><br><br><br>
<?php
if(isset($_POST['submit']))
{
$num = $_POST['val_num'];
$p=$num;
$revnum = 0;
while ($num != 0)
{
$revnum = $revnum * 10 + $num % 10;
$num = (int)($num / 10);
}
if($revnum==$p)
{
$display = "The given number " .$p." is Palindrome number.";
echo $display;
}
else
{
$display = "The given number " .$p. " is not Palindrome number.";
echo $display;
}
}
if(isset($_POST['clear']))
{
$display="";
}
?>
</body>
</html>
No comments:
Post a Comment