Write a PHP script to display Welcome message. Write a PHP script to demonstrate use of arithmetic operators, comparison operators, and logical operators || DWPD Sem 5 Practical 9

DWPD : Practical 9



1.PHP Script to display welcome message.<?php
   echo "Welcome to my website";
?>

Output :





2.PHP script to demonstrate use of arithmetic operators.<?php 
 $a=10;
 $b=20;
 
 $c=$a+$b;
 echo $c."<br>";
 
 $c=$a-$b;
 echo $c."<br>";
 
 $c=$a*$b;
 echo $c."<br>";
 
 $c=$a/$b;
 echo $c."<br>";
 
 $c=$a%$b;
 echo $c."<br>";
?> 

Output :

 

 

3.PHP script to demonstrate use of comparison operators<?php 
 $a=10;
 $b=20;

 //Comparison Operators
 
 if($a==$b)
 {
  echo "Both are equal"."<br>";
 }
 
 if($a===$b)
 {
  echo "Both are equal with same type"."<br>";
 }
 
 if($a!=$b)
 {
  echo "Both are Different"."<br>";
 }
 
 if($a<>$b)
 {
  echo "Both are Different"."<br>";
 }
 
 if($a!==$b)
 {
  echo "Both are Different but have same data type"."<br>";
 }
 
 if($a>$b)
 {
  echo "a is greater than b"."<br>";
 }
 
 if($a<$b)
 {
  echo "b is greater than a"."<br>";
 }
 
 if($a>=$b)
 {
  echo "a is greater or equal to b"."<br>";
 }
 
 if($a<=$b)
 {
  echo "a is less than b"."<br>";
 }
?>

Output : 




4. PHP script to demonstrate use of logical operators.<?php 
 $a=10;
 $b=20;

 //Logical operators
 
 if($a<$b && $b>$a)
 {
  echo "a is less than b and b is grater than a"."<br>";
 }
 
 if($a>$b || $b>$a)
 {
  echo "a is greater than b or b is grater than a"."<br>";
 }
  
 if(!isset($_SESSION['user']))
 {
  echo "User is not login"."<br>";
 }
?>


Output : 

Comments