You are on page 1of 5

Name:Parth Gala

Roll NP:16010421025

Batch:B3

<!DOCTYPE html>
<html>
<head></head>
<body>
<h1>Parth Gala</h1>
<?php
echo "Hello from Parth<br>";
?>
<?php
$age= 20;
echo "I am " . $age . " years old". "<br>";
echo "<br>";

$names = array("shreya", "akshat", "parmeet");


echo "My ".count($names)." friends are: " . $names[0] . ", " . $names[1] . " and
" . $names[2] . ".". "<br>";
echo "<br>";
echo "<br>";

$x = 542374;
var_dump($x);
echo "<br>";

$x = 673459.138412;
var_dump($x);
echo "<br>";
echo "<br>";

$x = "Parth";
$x = null;
var_dump($x);
echo "<br>";
echo "<br>";

$month = date("M");
echo "The current Month is: ".$month."<br>";
$t = date("H");
if ($t < "12") {
echo "Good morning";
}
else if($t < "18" and $t>"1"){
echo "Good afternoon";
}
else{
echo "Good Evening";
}
echo "<br>";
echo "<br>";

echo "This is my Favourite Car";

echo "<br>";

$favcar = "Volvo";
echo "String length is: ";
echo strlen($favcar);
echo "<br>";

switch ($favcar) {
case "Volvo":
echo "Your favorite car is Volvo!";
break;
case "BMW":
echo "Your favorite car is BMW!";
break;
case "Toyoto":
echo "Your favorite car is Toyoto!";
break;
default:
echo "Your favorite car is neither Volvo, BMW, nor Toyoto!";
}
echo "<br>";
echo "<br>";

$cars = array("Volvo", "BMW", "Toyota");


sort($cars);

$clength = count($cars);
for($x = 0; $x < $clength; $x++) {
echo $cars[$x];
echo "<br>";
}
echo "<br>";
echo "<br>";

$cars = array("Volvo", "BMW", "Toyota");


rsort($cars);

$clength = count($cars);
for($x = 0; $x < $clength; $x++) {
echo $cars[$x];
echo "<br>";
}
echo "<br>";
echo "<br>";

echo "This are examples of math functions";


echo "The share price of TCS is: "."$".rand(10, 100);

echo "<br>";
echo "Round functions";
echo(round(0.60));
echo(round(0.49));

echo "<br>";
$strng ="Parth";
var_dump($strng);
echo "<br>";
echo "This is reversed string: ";
echo strrev("Hello world!");
echo "<br>";
echo "This displays position of word: <br>";
echo strpos("My name is Parth", "Parth");

?>
</body>
</html>

Screenshot:
Post Lab Questions:-

1.Explain Loops in PHP with example.


Ans.

Loops are used to execute the same block of code again and again, as long as a certain condition is
true.

In PHP, we have the following loop types:

 while - loops through a block of code as long as the specified condition is true
 do...while - loops through a block of code once, and then repeats the loop as long as the
specified condition is true
 for - loops through a block of code a specified number of times
 foreach - loops through a block of code for each element in an array

2.Why chose PHP over other programming languages.


Ans.
Compared to other web languages, PHP doesn't require a manual or intensive studying. PHP
syntax is logical and well-organized. Even command functions are easy to understand, as they tell
the developer what function they perform. As a result, web developers find it very easy to create
and optimize the application.

Outcomes: Simple programs using basic PHP Constructs and String, Date, Time,Math in-
built functions

Conclusion: (Conclusion to be based on the objectives and outcomes achieved):


Learnt about XAMPP working and basic PHP tags also executed them on localhost with
chrome’s V8 engine

You might also like