Gurzi Posted March 5, 2008 Report Share Posted March 5, 2008 Boas, deparei-me agora com uma situação curiosa Se eu tiver numa varíavel o valor $cpto = " Error detected"; se eu fizer isto if($cpto == 0 ) , porque ele raio ele retorna true ? :x Link to comment Share on other sites More sharing options...
cyclop Posted March 5, 2008 Report Share Posted March 5, 2008 Talvez porque a variavel cpto nao está defenida.... logo retorna false... (visto que estas A verificar se é igual a zero ou FALSE ) "Quando eu for grande quero ser como o Celso" Link to comment Share on other sites More sharing options...
MX+ Posted March 5, 2008 Report Share Posted March 5, 2008 Confirmei isso agora.. Isso é muito estranho. Vou investigar Link to comment Share on other sites More sharing options...
MX+ Posted March 5, 2008 Report Share Posted March 5, 2008 Ok já percebi. Não costumo fazer comparaçoes de strings com números, porque mantenho uma certa rigidez no meu código mas está explicado: If you compare an integer with a string, the string is converted to a number. var_dump(0 == "a"); // 0 == 0 -> true http://pt.php.net/operators.comparison Link to comment Share on other sites More sharing options...
Gurzi Posted March 5, 2008 Author Report Share Posted March 5, 2008 Ok já percebi. Não costumo fazer comparaçoes de strings com números, porque mantenho uma certa rigidez no meu código mas está explicado: http://pt.php.net/operators.comparison Pois, enganei-me no código em cima, mas tinha os nomes iguais.. não sabia que ele convertia para numero :| Ok, gracias 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