A non well formed numeric value encountered
Because you are passing a string as the second argument to the date function, which should be an integer.
string date ( string $format [, int $timestamp = time() ] )
Try strtotime which will Parse about any English textual datetime description into a Unix timestamp (integer):
date("d", strtotime($_GET['start_date']));
Notice: A non well formed numeric value encountered PHP
Try
return (float)number_format((float)str_replace(",", ".", (string) $b2Cost), 2, ".", "");
But if you just want to shorten the float, take a look at https://www.php.net/manual/en/function.round.php
A non well formed numeric value encountered in laravel
This error usually pops up when you try to add an integer with a string or some type of non numeric field.
You can test this by using the PHP gettype()
method:
dump(gettype($product->mileage));
dd(gettype($oilchange));
If it turns out that one of these is a string (possibly from a form response), you can cast it to an int
if you are certain that the value will always be an int
.
$mileage = (int)$product->mileage;
Not really recommending this, as you should try to resolve the types within the variables first, but it may help you in testing.
How to solve a non well formed numeric value encountered in PHP?
number_format is function used for formatting strings. You may and should use it to view values, not to calculate them. You may change lines:
$grand_total = $tax + $sub_total;
$tax = number_format($tax,2);
But it would be a bit safer to use another variable:
$view_tax = number_format($tax,2);
$grand_total = $tax + $sub_total;
// now $grand_total uses $tax and to view
// tax, just use $view_tax variable
A non well formed numeric value encountered - Error in PHP
Use the code below :-
$totalvalue = 1.0 ; //Set $totalvalue and typecast to float
$value = 0.0 ;
$value = 2.5/100;
$totalvalue = $value * $totalvalue;
echo "<br>".$totalvalue;
number_format() causes error A non well formed numeric value encountered
Try type casting first parameter of number_format() to float:
$format = number_format((float)0, 2);
or
$format = number_format(floatval(0), 2);
PHP-7.4 Laravel Next ErrorException: A non well formed numeric value encountered
The error is specifically calling out line 35 of helpers.php:
$minutes = intval(($sec / 60) % 60);
What stands out to me here is the value is being converted to an integer however that's after the calculation has taken place. If you're trying to perform the calculation on a different value type, you're going to run into a problem.
Notice for instance that it didn't flag line 31:
$hours = intval(intval($sec) / 3600);
The difference is that $sec
is converted to an integer first.
I would move that conversion to the top of the function so that any calculation relying on the variable can be sure that it's an integer.
$sec = intval($sec);
...
$hours = intval($sec / 3600);
...
$minutes = intval(($sec / 60) % 60);
There are a number of other ways you may want to clean the function up but this should address the most immediate problem.
A non well formed numeric value encountered when creating a custom Yajra Datatable
The error occurs beacause the variables "start" and "end" in the ajax call are reserved keywords. I changed the name of the variables and it works now as aspected.
A non well formed numeric value encountered on if condition
This notice is thrown when you are trying to perform a math operation on a numeric value and a non-numeric type (string, bool, object etc.).
The reason that this may be happening in your code could be that either $from
or $to
are not valid date strings: see https://www.php.net/manual/en/datetime.formats.date.php and https://www.php.net/manual/en/datetime.formats.time.php for correct formatting.
Another possible reason is that your $conHour
does not have a valid numeric value.
EDIT: based on your update it is the latter: $conhour = string(5) "01:00"
you are trying to multiply a string. First (depending on how you get that variable) convert it in to a numeric value (1
) and then you will be able to multiply it
Related Topics
"Connect Failed: Access Denied For User 'Root'@'Localhost' (Using Password: Yes)" from PHP Function
PHP: Running Scheduled Jobs (Cron Jobs)
Pdo Valid Characters For Placeholders
What Does $$ (Dollar Dollar or Double Dollar) Mean in PHP
How to Send a Get Request from PHP
How to Detect Search Engine Bots With PHP
Parse Youtube Video Id Using Preg_Match
Sum Values of Multidimensional Array by Key Without Loop
Execute PHP Script in Cron Job
Efficient Jpeg Image Resizing in PHP
Laravel: Error [Pdoexception]: Could Not Find Driver in Postgresql
PHP Function to Get the Subdomain of a Url
Measuring the Distance Between Two Coordinates in PHP
Pdo::_Construct(): Server Sent Charset (255) Unknown to the Client. Please, Report to the Developers
How to Initialize Static Variables
How to Call Shell Script from PHP That Requires Sudo