Doc #80624 [Csd]: Undocumented change php 8 vs php 7 abs function

[email protected] Wed, 11 May 2022 10:51:40 +0000
Newsgroups php.doc.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=80624&edit=1

 ID:                 80624
 Updated by:         [email protected]
 Reported by:        ilyes dot ahidar at gmail dot com
 Summary:            Undocumented change php 8 vs php 7 abs function
 Status:             Closed
 Type:               Documentation Problem
 Package:            *Math Functions
 Operating System:   Linux Fedora 33
 PHP Version:        8.0.1
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

<https://3v4l.org/DXrcp> reports

| abs(): Argument #1 ($num) must be of type int|float, string given

In coercive type mode (the default) a string is juggled to an
int|float, if it is numeric[1].  An empty string is not considered
to be numeric.

[1] <https://www.php.net/manual/en/language.types.numeric-strings.php>


Previous Comments:
------------------------------------------------------------------------
[2022-05-11 10:20:14] post at andreas-mause dot de

It's only a problem on empty string-values:

<?php
$num = '';
var_dump(abs($num));// working not until PHP 8.0+
?>

But "" is a string, so it should working ... so it's a bug?!

------------------------------------------------------------------------
[2021-08-19 11:36:30] [email protected]

See <https://github.com/php/doc-en/commit/6c7c7edf76fd09ac0e91ed702727bccf32e548e4>.

------------------------------------------------------------------------
[2021-08-18 16:35:33] kawewong at gmail dot com

This also is not in these pages

https://www.php.net/manual/en/migration80.incompatible.php
https://www.php.net/manual/en/migration80.deprecated.php
https://www.php.net/manual/en/migration80.other-changes.php

I could not find info about this and just let my php run until one day there are unknown errors and I find out that it is incompatible.

<?php
$num = '1.00';
var_dump(abs($num));// working fine until PHP 8.0+
?>

Maybe please update any one of these page.

------------------------------------------------------------------------
[2021-05-23 11:27:57] [email protected]

Fixed as <https://github.com/php/doc-en/commit/e2a460ca39fece49eefdd5bd2282e5ba7b488fea>.

------------------------------------------------------------------------
[2021-05-19 16:17:10] [email protected]

Related To: Bug #81054

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=80624


--
Edit this bug report at https://bugs.php.net/bug.php?id=80624&edit=1