Created
March 8, 2012 01:50
-
-
Save danilowm/1997953 to your computer and use it in GitHub Desktop.
Função de Saudação (bom dia, boa tarde e boa noite)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function saudacao( $nome = '' ) { | |
| date_default_timezone_set('America/Sao_Paulo'); | |
| $hora = date('H'); | |
| if( $hora >= 6 && $hora <= 12 ) | |
| return 'Bom dia' . (empty($nome) ? '' : ', ' . $nome); | |
| else if ( $hora > 12 && $hora <=18 ) | |
| return 'Boa tarde' . (empty($nome) ? '' : ', ' . $nome); | |
| else | |
| return 'Boa noite' . (empty($nome) ? '' : ', ' . $nome); | |
| } | |
| echo saudacao(); | |
| // Irá retornar conforme o horário: | |
| // Bom dia | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment