Skip to content

Instantly share code, notes, and snippets.

@danilowm
Last active March 26, 2023 22:51
Show Gist options
  • Save danilowm/1997944 to your computer and use it in GitHub Desktop.
Save danilowm/1997944 to your computer and use it in GitHub Desktop.
Função de Saudação (bom dia, boa tarde e boa noite)
<?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