That's a PHP feature :)
-------------------------------------
> php -r "var_dump('0' == 'AR');"
bool(false)
> php -r "var_dump(0 == 'AR');"
bool(true)
----------------
If the first operand of comparison operator is integer then the second
is converted to integer. (int)'AR' is int(0).
With best regards,
Alexander Veremyev.
________________________________
From: Michel Morelli [mailto:[email protected]]
Sent: Monday, January 19, 2009 8:52 PM
To: [email protected]
Subject: [fw-general] Custom Validator, '0' == 'AR' is true ???
Hi all. I have this validator:
class validator_selectChoice extends Zend_Validate_Abstract
{
const SELECTCHOICE = 'selectChoice';
/*
* Rappresenta il valore di default che non deve essere quello
scelto dall'utente.
*/
private $_errorValue;
protected $_messageTemplates = array(
self::SELECTCHOICE => "You need to choice a value"
);
public function __construct($err = 0) {
$this->_errorValue = $err;
}
public function isValid($value)
{
$this->_setValue($value);
var_dump("E: $this->_errorValue");
var_dump("V: $value");
if ($value == $this->_errorValue) {
var_dump("iF!!!!!!!!!!!!!!!!!!!!");
$this->_error();
return false;
}
return true;
}
}
This is the debug log (via var_dump output)
string 'E: 0' (length=4)
string 'V: AR' (length=5)
string 'iF!!!!!!!!!!!!!!!!!!!!' (length=22)
string 'E: 0' (length=4)
string 'V: 5' (length=4)
string 'E: 0' (length=4)
string 'V: 1' (length=4)
Why '0' == ' AR' is true ?
Tnx.
--
Michel 'ZioBudda' Morelli [email protected]
Consulenza sistemistica in ambito OpenSource.
Sviluppo applicazioni web dinamiche (LAMP+Ajax)
Telefono: 0200619074
Telefono Cell: +39-3939890025 -- Fax: +39-0291390660
http://www.ziobudda.net ICQ: 58351764
http://www.ziobuddalabs.it Skype: zio_budda
http://www.ajaxblog.it MSN:
[email protected]
JABBER: [email protected]
No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.176 / Virus Database: 270.10.9/1900 - Release Date:
18.01.2009 12:11