PHP Programs

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

Program 11: Write a PHP program that checks if a string contains another string.


<!DOCTYPE html>
	<title>PHP Programs</title>
	<form method="GET" action="">
		Enter a string : <input type="Text" name="string1"><br/>
		Enter a substr : <input type="Text" name="string2"><br/>
		<input type="Submit" value="submit">

			$str1 =$_GET["string1"];
			$str2 =$_GET["string2"];

			echo "the string is :<br/> $str1 <br/>";
			echo "the substring is :<br/> $str2 ";

			if (strchr($str1,$str2))
				echo "<br/> The string contains the substring"; 
				echo "<br/> The string doesn't contain the substring";

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.