Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

PHP A non-numeric value encountered Warning

wyclef

Active Coder
Hi, I am getting a non-numeric value encountered warning on the line with the + in PHP 7.4. If I change the following from

PHP:
// Color picker
                case "color":
                    $default_color = '';
                    if ( isset($value['std']) ) {
                        if ( $smof_data[$value['id']] !=  $value['std'] )
 +                            $default_color = ' data-default-color="' .$value['std'] . '" ';
                    }
                    $output .= '<input name="' . $value['id'] . '" id="' . $value['id'] . '" class="of-color"  type="text" value="' . $smof_data[$value['id']] . '"' . $default_color .' />';
            
                break;

and add an (int) to

PHP:
// Color picker
                case "color":
                    $default_color = '';
                    if ( isset($value['std']) ) {
                        if ( (int)$smof_data[$value['id']] !=  $value['std'] )
 +                            $default_color = ' data-default-color="' .$value['std'] . '" ';
                    }
                    $output .= '<input name="' . $value['id'] . '" id="' . $value['id'] . '" class="of-color"  type="text" value="' . $smof_data[$value['id']] . '"' . $default_color .' />';
            
                break;

The error goes away but shouldn’t I also be adding an (int) in front of $default_color too? Basing this on this link Warning: A non-numeric value encountered
 
if ( (int)$smof_data[$value['id']] != $value['std'] )

That compares the integer value of $smof_data[$value['id']] to $value['std'] ) which is type of what? If its boolean, double, string, char, floating etc. it causes an warning or error depending of context.
 

New Threads

Buy us a coffee!

Back
Top Bottom