php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73468 PHP 7.1: PHP Notice: A non well formed numeric value encountered
Submitted: 2016-11-06 19:37 UTC Modified: 2017-09-10 20:17 UTC
From: spam2 at rhsoft dot net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 7.1.0RC5 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: spam2 at rhsoft dot net
New email:
PHP Version: OS:

 

 [2016-11-06 19:37 UTC] spam2 at rhsoft dot net
Description:
------------
in 7.0 the warnings when something in a string *looks like* something where bad but *that* is just kidding

[06-Nov-2016 20:29:39 Europe/Vienna] PHP Notice:  A non well formed numeric value encountered in /Volumes/dune/www-servers/rhsoft/status.php on line 470
<td colspan="5"><?=GetSizeString('', ($dbsize*1024))?></td>

[06-Nov-2016 20:16:15 Europe/Vienna] PHP Notice:  A non well formed numeric value encountered in /Volumes/dune/www-servers/phpincludes/global_rh_misc.inc.php on line 1883 
$Diff = round($BalkenBreite - $AktBreite + 1, 2) . 'px;';



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-06 19:41 UTC] spam2 at rhsoft dot net
ok, now i get puke

Notice: A non well formed numeric value encountered in /Volumes/dune/www-servers/rhsoft/status.php on line 466

$dbsize_bytes = $dbsize*1024;

that's just a simple multiplication, no formatting, no magic
 [2016-11-06 19:46 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2016-11-06 19:46 UTC] nikic@php.net
What is the value of $dbsize? Probably something like "128K", which is not a number. If you want to suppress the warning, use an explicit (int) cast.

See https://wiki.php.net/rfc/invalid_strings_in_arithmetic for more information.
 [2016-11-06 19:49 UTC] spam2 at rhsoft dot net
(floatval($dbsize)*1024) 
((float)$dbsize*1024))

are workarounds - but sicne when is PHP a strong typed language?
 [2016-11-06 19:53 UTC] spam2 at rhsoft dot net
4077 KB - in other words we have now to typecast everything in doubt which PHP did for more than a decade itself?
 [2016-11-06 21:42 UTC] spam2 at rhsoft dot net
and BTW - fine that you mention the codeline - what about mention the VARIABLE which the warning is raising?
 [2017-09-10 19:41 UTC] develway at gmail dot com
I don't get the point about solution?
for example for this simple code in the last line I get the same
Notice: A non well formed numeric value encountered

const BR = "<br>";

$a = 1;
$b = 2.5;
$c = 0xFF;
echo $d = $b + $c . BR;
echo $e = $d * $b . BR;
 [2017-09-10 19:59 UTC] develway at gmail dot com
I wanted to say, that I don't get what solution must be ...

const BR = "<br>";

$a = 1;
$b = 2.5;
$c = 0xFF;
echo $d = $b + $c . BR;
echo $e = $d * $b . BR;

In the last line the result expected to be float, why appears this Notice:
A non well formed numeric value encountered?
 [2017-09-10 20:08 UTC] develway at gmail dot com
Notice disappear, but code is ugly :)

echo (float)$e = (float)$d * (float)$b . BR;

I agree that now to avoid Notice we must to typecast expected result, what PHP did for more than a decade itself!!!
 [2017-09-10 20:13 UTC] develway at gmail dot com
echo $d = $b + $c . BR; //but why PHP doesn't understand that is float?
echo $e = (float)$d * $b . BR;
 [2017-09-10 20:17 UTC] requinix@php.net
@develway: This isn't a blog. If you think you found a bug (you didn't) then make your own bug report.
$d is "257.2<br>". http://php.net/manual/en/language.operators.precedence.php
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jun 07 13:01:27 2025 UTC