cjjesus Posted July 28, 2012 at 01:16 PM Report Share #470787 Posted July 28, 2012 at 01:16 PM (edited) saudaçoes. estou a preparar o seguinte codigo: <?PHP #OBJECTIVO:<br> #NOME:Carlos<br> #IDADE:20 anos<br> #SIGNO:leão<br> #============================== $hoje = explode("-",date('Y-m-d'));# o dia hoje $data = '1980-08-31'; #MYSQL data aniversario $result = $data - date('Y-m-d');#subtrair $result = $data - $hoje = 'x' anos $dia = explode("-", $data); #partir $data = $dia $mes $ano print'OBJECTIVO:<br> #NOME:Carlos<br> #IDADE:'.$result.' anos<br> #SIGNO:'; #switch case $dia < '23' && $mes='7' = 'Leao' ... switch($hoje[2]){ case $dia[2] > '23' && $dia[1]=='1': echo "Aquario"; break; case $dia[2] > '23' && $dia[1]=='2': echo "Peixes"; break; case $dia[2] > '23' && $dia[1]=='3': echo "Carneiro"; break; case $dia[2] > '23' && $dia[1]=='4': echo "Touro"; break; case $dia[2] > '23' && $dia[1]=='5': echo "Gemeos"; break; case $dia[2] > '23' && $dia[1]=='6': echo "Caranguejo"; break; case $dia[2] > '23' && $dia[1]=='7': echo "Leão"; break; case $dia[2] > '23' && $dia[1]=='8': echo "Virgem"; break; case $dia[2] > '23' && $dia[1]=='9': echo "Balança"; break; case $dia[2] > '23' && $dia[1]=='10': echo "Escorpião"; break; case $dia[2] > '23' && $dia[1]=='11': echo "Sagitário"; break; case $dia[2] > '23' && $dia[1]=='12': echo "Capricórnio"; break; } print'<br>#=============================='; ?> gostaria de poder contar com sujestões obrgd 😉 Edited July 30, 2012 at 03:48 PM by cjjesus geshi Link to comment Share on other sites More sharing options...
KTachyon Posted July 28, 2012 at 01:56 PM Report Share #470789 Posted July 28, 2012 at 01:56 PM Tendo em conta que isso não funciona, a única sugestão que tenho a dar é utilizares if em vez de switch. “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare Link to comment Share on other sites More sharing options...
tiagotavares Posted July 28, 2012 at 10:30 PM Report Share #470827 Posted July 28, 2012 at 10:30 PM Boas repara que em cada case estas a atribuir um valor em vez de comparar. Pois estas apenas a usar 1 sinal = Tiago Tavares Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now