dimanche 3 avril 2016

Trying to make a time based greeting on php and include to html but received error

I was trying to make a local time based greeting message appear on my html page. But this just won't work.

php file

<?php 
var $now = new Date();
var $hrs = now.getHours();
var $greet = "";

if (hrs >  0) $greet = "Mornin' Sunshine!"; // REALLY early
if (hrs >  6) $greet = "Good morning";      // After 6am
if (hrs > 12) $greet = "Good afternoon";    // After 12pm
if (hrs > 17) $greet = "Good evening";      // After 5pm
if (hrs > 22) $greet = "Go to bed!";        // After 10pm

int print ( string $greet );
?>

html include

<div id="greet">
    <?php include './function/greetings.php';?>
</div>

How can I solve this?




Aucun commentaire:

Enregistrer un commentaire