Welcome, guest | Sign In | My Account | Store | Cart

In usually we say welcome in our page with simple like "welcome user" adn etc but I think if we can say like "Hello, good morning user" its more interactive say. It can be done with simple using date() or time function in php.

PHP, 13 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
function sayhello(){
 $hours=date("G")+0;
 ### you can set own criteria in your country
 ### whats time we must say good morning and etc
 if( $hours>=0 &&  $hours<=14) $hellowords="Good Morning";
 elseif( $hours<=18) $hellowords="Good Afternoon";
 else $hellowords="Good Night";
 return $hellowords;
}


### calling in your script with
### echo "Hello user, ".sayhello();
Created by imam ferianto on Mon, 30 Jun 2003 (MIT)
PHP recipes (51)
imam ferianto's recipes (8)

Required Modules

  • (none specified)

Other Information and Tasks