You are on page 1of 4

ArithmeticOperators.

php
<html>
<title>
Arithmetic operators
</title>
<body>
<center> <h3> Arithmetic Operators </h3></center>
<?php
$a = 5;
$b = 12;
$c = $a + $b;
echo "Sum of $a and $b is $c <br>";
$d = $c - $a;
echo "Difference of $c and $a is $d <br>";
$e = $d * $c;
echo "Product of $d and $c is $e";
?>
</body>
</html>
FirstPhp.php

<html>
<head></head>
<body>
<div>
<?php echo “Hello”; ?>
</div>
</body>
</html>

Example2.php

<html>
<body>
<?php
//Program to demonstrate echo
echo "<br>Example of echo statement<br>";
$name = "aaa";
echo "\nName is <b>'".$name."'";
?>
</body>
</html>
VariableEx.php
<html>
<body>
<?php
// assign value to variable
$a = 'PHP';
// print variable value
echo $a;
// assign an integer value to the same variable
$a = 5;
// print variable value
echo $a;
?>
</body>
</html>

VardumpEx.php

<html>
<body>
<?php
$a = 67854;
var_dump($a);
$x = 10.365;
var_dump($x);
$s = "Hello world!-Double Quoted";
$s1 = 'Hello world!-Single Quoted';
echo $s;
echo "<br>";
echo $s1;
?>
</body>
</html>

PHPobject.php

<html>
<body>
<?php
class Employee {
public $empId;
public $name;
public $dept;
public function __construct($empId, $name,
$dept) {
$this->empId = $empId;
$this->name = $name;
$this->dept = $dept;
}
public function message() {
return "Employee ID: " . $this->empId .
"Employee Name : " . $this->name . " Department : ".$this-
>dept;
}
}
$emp = new Employee(1001,"Priya","Admin");
echo $emp -> message();
echo "<br>";
$emp = new Employee(1003,"Swetha","Accounts");
echo $emp -> message();
?>
</body>
</html>

ComparisonOp.php
<html>
<body>
<?php
$a = 5;
$b = 6;
if($a == $b)
echo "$a is equal to $b<br>";
if($a === $b)
echo "$a is identical $b<br>";
if($a != $b)
echo "$a is not equal to $b<br>";
if($a !== $b)
echo "$a is not identical to $b<br>";
if($a < $b)
echo "$a is less than $b<br>";
if($a > $b)
echo "$a is greater than $b<br>";
if($a <= $b)
echo "$a is less than or equal to $b<br>";
if($a >= $b)
echo "$a is greater than or equal to $b<br>";
if($a <> $b)
echo "$a is not equal to $b<br>";
?>
</body>
</html>

You might also like