Professional Documents
Culture Documents
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>";
$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 "<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>";
$clength = count($cars);
for($x = 0; $x < $clength; $x++) {
echo $cars[$x];
echo "<br>";
}
echo "<br>";
echo "<br>";
$clength = count($cars);
for($x = 0; $x < $clength; $x++) {
echo $cars[$x];
echo "<br>";
}
echo "<br>";
echo "<br>";
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:-
Loops are used to execute the same block of code again and again, as long as a certain condition is
true.
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
Outcomes: Simple programs using basic PHP Constructs and String, Date, Time,Math in-
built functions