Last active
March 26, 2023 22:51
-
-
Save danilowm/1997944 to your computer and use it in GitHub Desktop.
Função de Saudação (bom dia, boa tarde e boa noite)
This file contains 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); | |
} | |
$login = 'Danilo Iannone'; | |
echo saudacao( $login ); | |
// Irá retornar conforme o horário: | |
// Bom dia Danilo Iannone | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment