icon picker
Project 2: PHP

Intro

A popular general-purpose scripting language that is especially suited to web development. Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world.

Setup

Click on:
Copy/paste this text into the left side of the screen and click “Run”:
<html>

<head>
<title>Merit Badge Test</title>
<style>
body {
font-family: Helvetica, sans-serif;
margin: 10px;
background-color: #D6CEBD;
color: #003F87;
}
</style>
</head>

<body>
<h2>What Time Is It?</h2>
<?php
$now = localtime(time(), true);
$num_minutes = $now[tm_min];
$num_seconds = $now[tm_sec];
$remaining_seconds = 60 - $num_seconds;

echo "The time is " . date("h:i:sa");

if ($num_seconds < 30) {
echo '<p>First half of the minute!</p>';
} else {
echo '<p>Second half of the minute!</p>';
}
echo "There are " . $remaining_seconds . " seconds before the minute is over.<br>";
echo "<hr/>";
echo "<ul>";
for ($i = 0; $i < 10; $i++) {
echo "<li>Counting: " . $i . "</li>";
}
echo "</ul>";
?>
</body>

</html>

Your Turn

Make the following changes:
Copy the code that checks the seconds, and have it do the same thing with num_minutes (i.e. print first half or second half of the hour).
Add an if statement that prints “Troop 13” or “Troop 15” if the number of seconds is 13 or 15 respectively.

More Info

To learn more about PHP visit:


Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.