PHP and strings close to maxint?

Invited scholars "to think")

Found a strange behavior of such code.
$id1 = '9223372036854775888';<br>
$id2 = '9223372036854775899';<br>
var_dump($id1 == $id2);<br>



The result is true. In Manet it is said that numeric strings are compared as integers. What should guide what should I invent? Ie when a previously unknown kind of compared strings, you can get anything on the output.
October 8th 19 at 02:22
4 answers
October 8th 19 at 02:24
Make a small post in the tape, everyone should know. "Bag" hangs from 2007 so it is unlikely that anything will change: bugs.php.net/bug.php?id=43304
Turns out, they documented it, my IDE is older than the documentation where about
Type conversion does not happen when using ===
there is no word. - Luz.Thomps commented on October 8th 19 at 02:27
October 8th 19 at 02:26
A dangerous thing, I also have a TRU ==, === falls.

when you specify a type (string) even TRU
Looked Mans, Mans says that numeric strings are compared as integers. I hadn't thought about it, but how much code is subject to a potential error? - Luz.Thomps commented on October 8th 19 at 02:29
To me honestly not go wherever to try it. Database to recognize different strings. - Luz.Thomps commented on October 8th 19 at 02:32
October 8th 19 at 02:28
use = = = Luke
Then why is the explicit type does not work? - Luz.Thomps commented on October 8th 19 at 02:31
Because the head developers of php came idiotic idea to compare the number strings as integer values. Than was guided in making this decision is a mystery. - Luz.Thomps commented on October 8th 19 at 02:34
you have to compare float is not reached. - stella_Rat commented on October 8th 19 at 02:37
two float together? - stella_Rat commented on October 8th 19 at 02:40
October 8th 19 at 02:30
What should guide what should I invent?

The fact that PHP was originally a templating engine, working with text data (logon script from the web server, the records in the database files, all rows), but data are often numerical in nature. That and "facilitate" the life of developers, so there was no need for everyone types of lead.

Remember stumbled upon this dubious "feature" were compared like this: $str1. 'fake' == $str2. 'fake'
Hmm, a great example of a crappy language design. - Luz.Thomps commented on October 8th 19 at 02:33
Well, why "crappy"? After all, it had slightly different goals, and then rethink did not. This has both pros and cons. Bugs in any case, conventional coders to catch. - Luz.Thomps commented on October 8th 19 at 02:36
Here you like to criticize =))))

For example, try to prescribe rigidly the type of each variable which is in your project. And then (when it does), rate how much it is labor-intensive use "===" instead of "==". - stella_Rat commented on October 8th 19 at 02:39

Find more questions by tags PHP