note 5146 deleted from language.operators.comparison by sniper
| From: | sniper@php.net | Date: | Mon, 13 Oct 2003 00:15:41 +0000 |
| Subject: | note 5146 deleted from language.operators.comparison by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58427@lists.php.net to get a copy of this message | ||
Note Submitter: dhosek@excite.com
----
Agreed about the bogosity of the comparisons and loose typing.
What I've found is a workable way to insure that your type is what is expected:
If you want to guarantee a string suffix the variable with . "" (that is concatenate an
empty string to the end). The value is unchanged, but the type is forced. To guarantee an integer,
suffix with +0 (same effect, although a non-numeric string will be transformed into 0).
[Or you just cast your types - Ed.]