PHP Programs

Please click on 1-2 Ads to keep this website's Study Material FREE and regularly Updated.

Program 8: Write a PHP program that checks whether a passed string is palindrome or not.

palindrome.php

<!DOCTYPE html>
<html>
<head>
	<title>PHP Programs TutorialDuniya.com</title>
</head>
<body>
	<form method="GET" action="">
		Enter a string: <input type="Text" name="string1"><br>
		<input type="Submit" name="submit" value="Palindrome">
	</form>

	<?php
		if (isset($_GET["submit"]) == "Palindrome")
		{
			$str1=$_GET["string1"];
			echo "the string is : $str1 <br>";

			$str2=strrev($str1);
			echo "<br> reversed string is: $str2";

			if($str2==$str1)
				echo"<br> The string is palindrome";
			else
				echo"<br> The string is not palindrome";
		}
	?>
</body>
</html>



If you have any suggestion or found any error in the above program, then do let us know at [email protected] or just comment below.