Warning: A non-numeric value encountered

This warning message is indicating that a non-numeric value has been encountered in a place where a number is expected. This can occur when a string is being used in a mathematical operation or when a variable that is supposed to contain a number contains a string instead.

To fix this issue, you will need to make sure that you are only performing mathematical operations on numbers. If you are trying to perform an operation on a variable that may contain a string, you will need to first check the type of the variable and convert it to a number if necessary.

Watch a course Learn object oriented PHP

For example, you can use the is_numeric() function to check if a variable is a number or a string representation of a number, and use the intval() or floatval() functions to convert a string to an integer or float, respectively.

Here is an example of how you can use these functions to safely perform a mathematical operation on a variable:

<?php

$value = "123"; // or any other value

if (is_numeric($value)) {
    $result = $value + 10;
    echo "$value is a numeric value." . PHP_EOL;
    echo "Adding 10 to $value gives $result." . PHP_EOL;
} else {
    $result = 0;
    echo "$value is not a numeric value." . PHP_EOL;
    echo "The result is $result." . PHP_EOL;
}