Subscribe:Posts Comments

You Are Here: Home » Pemprogaman PHP » PHP Script – Menyapa berdasar Waktu

Script PHP berikut akan menyapa user berdasarkan waktu, simpan script dibawah ini dengan nama hello.php

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>greeting :) </title>
<style type=”text/css”>

body{
width:100#;
margin:0;
padding:0;
font-family: “Trebuchet MS”, Arial, Helvetica, sans-serif;
font-size:12px;
color:#666666;
}

/* Bar top */
#bar{
}

#bar table{
width:100%;
}

#bar td{
height:12px;
background-color:#F3F3F3;
border-bottom:#CCCCCC 2px solid;
}

#bar p{
padding: 2px 5px;
text-transform:capitalize;
}

</style>
</head>
<body>

<?php
function greeting()
{
$date = date (“G : i A”);
if ($date < 12) {
echo “$date | Have a nice day”;
} else if ($date < 18){
echo “$date | komputerBLOG.com”;
} else echo “$date | Good night”;
}
?>

<!– Bar –>
<div id=”bar”>
<table>
<tr>
<td><p><? greeting(); ?></p></td>
</tr>
</table>
</div>
</body>
</html>

Semoga bermanfaat

Leave a Reply

© 2008 KomputerBLOG.Com · Subscribe:PostsComments · Designed by Theme Junkie · Powered by WordPress

Switch to our mobile site