[PHP Hater] Motivos para odiar PHP. Capítulo I

Iniciado por Jimeno, Mayo 04, 2015, 12:28:14 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Mayo 04, 2015, 12:28:14 PM Ultima modificación: Mayo 04, 2015, 12:33:24 PM por Jimeno
Os dejo un motivo para odiar PHP con toda vuestra alma:



Código:
Código: php
<?php
if ("0" == "0e830400451993494058024219903391") {
echo "fuck";
}
?>



EDITO:
Explicación:
PHP castea todo lo que parece un número a float y luego lo compara, es decir, "1e3" == "1000" devolvería true.
Recomiendan usar strcmp() para este tipo de comparaciones.



Saludos.
Contacto: @migueljimeno96 -

Usa el operador de identidad '===' saludos

Citar$a === $b   Idéntico   TRUE si $a es igual a $b, y son del mismo tipo.
Pentest - Hacking & Security Services

Contact me: You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login

no me parece para nada un motivo para odiar un lenguaje.


Aquí tienes un caso más práctico donde puedes ver los peligros que puede tener:
Contacto: @migueljimeno96 -

Mayo 04, 2015, 10:45:16 PM #4 Ultima modificación: Mayo 04, 2015, 11:01:31 PM por arthusu
You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
En este caso te ves en la misma situación con == que con ===





You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login

Saludos!
Pentest - Hacking & Security Services

Contact me: You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login

Borro lo otro y pido perdón por el fallo, thx arthusu
Contacto: @migueljimeno96 -