Greeting the Guests & Users

mikeSQL 0 Tallied Votes 121 Views Share

This tutorial shows how to greet your visitors depending on what time of day it is. If it's morning, it greets your visitor with "Good Morning!" If it's afternoon, it greets them with "Good Afternoon!" Magic? Noooo! Just PHP!

We will start by looking at the entire script and then dissecting it afterward.
The Tutorial of this so you cn understand will be piosted in the Tutorials Section of this site.

<?php

//Here we define out main variables
$welcome_string="Welcome!";
$numeric_date=date("G");

//Start conditionals based on military time
if($numeric_date>=0&&$numeric_date<=11)
$welcome_string="Good Morning!";
else if($numeric_date>=12&&$numeric_date<=17)
$welcome_string="Good Afternoon!";
else if($numeric_date>=18&&$numeric_date<=23)
$welcome_string="Good Evening!";

//Display our greeting
echo "$welcome_string";

?>
mikeSQL 5 Junior Poster

Hey its nice to come back after sooooo many months and your cool looking snippets still here!

Dani 4,084 The Queen of DaniWeb Administrator Featured Poster Premium Member

Haha! :) Welcome back.

siddhugen 0 Newbie Poster

hi, i want to build login & register page useing php5.2& oracle 10g exp ed. can u help me

LloydFarrell 0 Junior Poster

Hi, I was wondering how i could use your code snippet to determine the local time of users.

I am hosting with godaddy at the moment and the time difference is causing some minor time issues.

Is it possible, or how could i interact and retrieve the users local time ?

Hoping you reply positivley,

regards
lloyd

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.