Re: [PHP] How can an elephant count for nothing?

2009-02-13 Thread Yeti
I guess the main reason for PHP to behave like this is to make life easier for many everyday situations. EXAMPLE: User input via GET or POST - usually string You compare it to some value - int/string or whatever So if a user posts '17' (string) and you compare it to 17 (int), unless you are

Re: [PHP] How can an elephant count for nothing?

2009-02-13 Thread Virgilio Quilario
While PHP has a lot of nice features, it also has some traps which I am forever falling into. One which I find particularly hard to understand is how mixed mode comparisons work. For instance $string = 'elephant'; If($string == 0) returns true; If($string != 0) returns false;

Re: [PHP] How can an elephant count for nothing?

2009-02-12 Thread Per Jessen
Clancy wrote: While PHP has a lot of nice features, it also has some traps which I am forever falling into. One which I find particularly hard to understand is how mixed mode comparisons work. For instance $string = 'elephant'; If($string == 0) returns true; If($string != 0) returns

Re: [PHP] How can an elephant count for nothing?

2009-02-12 Thread Jochem Maas
Clancy schreef: While PHP has a lot of nice features, it also has some traps which I am forever falling into. One which I find particularly hard to understand is how mixed mode comparisons work. For instance $string = 'elephant'; If($string == 0) returns true; If($string != 0)

Re: [PHP] How can an elephant count for nothing?

2009-02-12 Thread Yeti
Can anyone explain clearly why comparing a string with zero gives this apparently anomalous result? ?php $string = 'oleyphoont'; var_dump((int)$string, $string == 0, $string == 1); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] How can an elephant count for nothing?

2009-02-12 Thread Dotan Cohen
Have you tried with a mouse? -- Dotan Cohen http://what-is-what.com http://gibberish.co.il א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת ا-ب-ت-ث-ج-ح-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه‍-و-ي А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я

Re: [PHP] How can an elephant count for nothing?

2009-02-12 Thread 惠新宸
Jochem Maas wrote: Clancy schreef: While PHP has a lot of nice features, it also has some traps which I am forever falling into. One which I find particularly hard to understand is how mixed mode comparisons work. For instance $string = 'elephant'; If($string == 0) returns

Re: [PHP] How can an elephant count for nothing?

2009-02-12 Thread Shawn McKenzie
惠新宸 wrote: Jochem Maas wrote: Clancy schreef: While PHP has a lot of nice features, it also has some traps which I am forever falling into. One which I find particularly hard to understand is how mixed mode comparisons work. For instance $string = 'elephant'; If($string == 0)

Re: [PHP] How can an elephant count for nothing?

2009-02-12 Thread Ashley Sheridan
On Thu, 2009-02-12 at 13:12 +0200, Dotan Cohen wrote: Have you tried with a mouse? Non-strings equate to a boolean value of 1 when they are converted to a boolean value automatically (in the case of comparison queries) when they contain a value. Strings of 0 length are converted to a 0. In

Re: [PHP] How can an elephant count for nothing?

2009-02-12 Thread Clancy
On Thu, 12 Feb 2009 23:47:31 +0800, huixinc...@baidu.com (???) wrote: Jochem Maas wrote: Clancy schreef: While PHP has a lot of nice features, it also has some traps which I am forever falling into. One which I find particularly hard to understand is how mixed mode comparisons work.