i have this code:
$password_introducido = sfContext::getInstance()->getUser()->getGuardUser()->setPassword($value['password_actual']);
$password_almacenado = sfContext::getInstance()->getUser()->getGuardUser()->getPassword();
var_dump("kfjsdlkjf");
var_dump($password_almacenado);
var_dump($password_almacenado);
if($password_introducido == $password_almacenado){
die("entrosopi")开发者_如何学运维;
}
that prints this:
string 'kfjsdlkjf' (length=9)
string 'c9c40d11b29ac0f5bdef3be51ce61187582c3ae1' (length=40)
string 'c9c40d11b29ac0f5bdef3be51ce61187582c3ae1' (length=40)
IMHO, it should print "entrosopi", but it doesnt. Why?
If i instead write
if(!$password_introducido == $password_almacenado)
it prints "entrosopi".
Javi
You realize you are outputting the same string right?
Try this:
var_dump("kfjsdlkjf");
var_dump($password_introducido);
var_dump($password_almacenado);
Tell us what it outputs.
They are most likely NOT equal to each other.
One of the functions (most likely setPassword) is encrypting/hashing the value for security.
Use ===
for exact, literal comparison.
For details, see this related question: if(0 == '%') echo "WTF, Php, why can't you compare things sanely?"
精彩评论