0% found this document useful (0 votes)
9 views10 pages

PHP 1

Uploaded by

shrikantmore3896
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views10 pages

PHP 1

Uploaded by

shrikantmore3896
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

PHP(22619) GTMC

GRAMIN TECHNICAL AND MANAGEMENT CAMPUS,VISHNUPURI


NANDED.
Name: Sanket Ramchandra Chonde Class:- CO6I(B)
Roll No:- 02

PRACTICAL NO: 1
XAMPP INSTALLATION

 Step 1:-
PHP(22619) GTMC

 Step 2:-

 Step 3:-
PHP(22619) GTMC

 Step 4:-

 Step 5:-
PHP(22619) GTMC

Q.Write a program to print “ Welcome to PHP”.


Code:-
<?php
echo("<h1><b>Welcome to PHP </b></h1>");
?>

Output:-
PHP(22619) GTMC

 Arithmetic Operators
Code:-
<?php
$a = 45;
$b = 18;
print("<h2>Arithmetic Operators</h2>");
echo "First number: $a <br/>";
echo "Second number: $b <br/><br/>";
$c = $a + $b;
echo "Add: $c <br/>";
$c = $a - $b;
echo "Sub: $c <br/>";
$c = $a * $b;
echo "Mul: $c <br/>";
$c = $a / $b;
echo "Div: $c <br/>";
$c = $a % $b;
echo "Mod: $c <br/>";
?>

Output:-
PHP(22619) GTMC

 Assignment Operator:
Code:-
<?php
$a = 45;
$b = 18;
print("<h2>Assignment Operators</h2>");
echo "a = $a <br/>";
$a += 10;
echo "a = a + 10: $a <br/>";
$a -= 10;
echo "a = a - 10: $a <br/>";
$a *= 10;
echo "a = a * 10: $a <br/>";
$a /= 10;
echo "a = a / 10: $a <br/>";
$a %= 10;
echo "a = a % 10: $a <br/>";
?>

Output:-
PHP(22619) GTMC

 String Operators
Code:-
<?php
$a = 3;
$b = 2;
print("<h2>String Operators</h2>");
$A = 'Rohit ';
$y = 'I';
echo "A: $A <br/>";
echo "y: $y <br/>";
$name = $A . $y;
echo "name: $name <br/>";
$A .= "Sharma";
echo "a: " . $A . "<br/>";
?>

Output:-
PHP(22619) GTMC

 Ternary and Bitwise Operators


Code:-
<?php
$a = 45;
$b = 18;
print("<h2>Ternary/Conditional Operators</h2>");
$x = -10;
echo "x = $x <br/>";
echo ($x > 0) ? 'The number is positive' : 'The number is negative';

print("<h2>Bitwise Operators</h2>");
echo "a = $a, b = $b<br/>";
echo "Bitwise AND (a & b): " . ($a & $b) . "<br/>";
echo "Bitwise OR (a | b): " . ($a | $b) . "<br/>";
echo "Bitwise XOR (a ^ b): " . ($a ^ $b) . "<br/>";
echo "Bitwise NOT (~a): " . (~$a) . "<br/>";
echo "Left Shift (a << 1): " . ($a << 1) . "<br/>";
echo "Right Shift (a >> 1): " . ($a >> 1) . "<br/>";

?>

Output:-
PHP(22619) GTMC

Q1.Write a various comaparison operators in PHP with Example.


Code:-
<?php
$a = 45;
$b = 18;
$c = 93;

print("<h2>Comparison Operators</h2>");
echo('$a == $c : ');
var_dump($a == $c);
echo "<br/>";
echo('$a != $b : ');
var_dump($a != $b);
echo "<br/>";
echo('$a <> $b : ');
var_dump($a <> $b);
echo "<br/>";
echo('$a === $c : ');
var_dump($a === $c);
echo "<br/>";
echo('$a != $c : ');
var_dump($a != $c);
echo "<br/>";
echo('$a < $b : ');
var_dump($a < $b);
echo "<br/>";
echo('$a > $b : ');
var_dump($a > $b);
echo "<br/>";
echo('$a >= $b : ');
var_dump($a >= $b);
echo "<br/>";
echo('$a <= $b : ');
var_dump($a <= $b);
echo "<br/>";
?>
Output:-
PHP(22619) GTMC

Q2.Write a various Logical operators in PHP with Example.


Code:-
<?php
$x = 45;
$y = 18;
print("<h2>Logical Operators</h2>");
if ($x < $y && $y > 5) {
echo "Both conditions are true.\n";
}
if ($x > 10 || $y < 20) {
echo "At least one condition is true.\n";
}
if (!($x == 10)) {
echo "$x is not equal to 10.\n";
}
?>
Output:-

You might also like