Mailinglisten-Archive |
Thomas Winter wrote:
> Hallo Liste,
>
> $a = '000';
> $b = '000000';
>
> if ( $a != $b ) {
> print "<br>Info NICHT gleich";
> }
>
> Ich hätte erwartet das es ungleich ist, zumal $a und $b vom Typ string
> sind.
Dem ist nicht so, wie du siehst. Auszug aus der manual:
"If you compare two numerical strings, they are compared as integers"
>
> Wie soll man das am besten abfangen?
Das hängt davon ab, was du willst.
Ich habe den Eindruck, dass du dies hier willst:
if ((string)$a !== (string)$b) echo "Nicht gleich\n";
>
> Gruß
> Thomas
>
Yannik
php::bar PHP Wiki - Listenarchive