Lets have a simple PHP script
<?php
var_dump("php" == 0);
According to official documentation (https://www.php.net/manual/en/types.comparisons.php)
, this shoud evaulate into true
BUT
It does, for PHP <=7.4, but no for PHP 8.0
In current version of PHP 8 (8.0.0 – 8.0.2) it evaulates to false
.
Are there any un-documented changes to this functionality or is this a bug? Or am I missing something?
Thank you
3
Answers
When PHP 8 got released, they also put a release announcement on the website. This is part of one of the new major changes, the saner string to number comparison.
To quote:
This behavior is documented in Backward incompatible changes.
PHP Documentation maintainer here, PHP 8 did change the semantics and this is shown in the migration guide. However other parts of the documentations are still lagging behind as we don’t have the manpower/time for editing and documenting all the changes related to PHP 8.
So this is not a bug and more a fact that the current type juggling page is out of date in regards to PHP 8.0.
It is possible to contribute to the docs via a Pull Request to the GitHub repository.