PHP 7 Script to Check or Verify Whether the Given Number or String is Palindrome or Not in Browser Full Project For Beginners

  • Post author:
  • Post category:PHP
  • Post comments:0 Comments

 

Welcome folks today in this blog post we will be checking or verifying whether the given number or string is palindrome or not in browser using php 7. All the full source code of the application is shown below.

 

 

 

Get Started

 

 

 

In order to get started you need to make an index.php file and copy paste the following code

 

 

index.php

 

 

 

<html>
<body>
<form method="post">        
Enter a Number/String: <input type="text" name="num"/><br>  
<button type="submit">Check</button>  
</form>  
</body>

</html>

<?php   
    if($_POST)  
    {  
        //get the value from form  
        $num = $_POST['num'];  
        //reversing the number  
        $reverse = strrev($num);  
          
        //checking if the number and reverse is equal  
        if($num == $reverse){  
            echo "The number/string $num is Palindrome";     
        }else{  
            echo "The number/string $num is not a Palindrome";   
        }  
}     
      ?>

Leave a Reply