Skip to content

Uncaught TypeError: Unsupported operand types: string * string in  #7895

@tolgahanacar

Description

@tolgahanacar

I'm pulling currency api with json_decode.

I can read the data properly, but it returns problems with multiplication.
Sample;
['USD']['sale'] * $value

The following code:

<?php
$value1 = $_POST['value1'] // var_dump: string
$value2 = $_POST['value2'] // var_dump: string or int

echo $value1 * $value2; // example 1 * 3

Resulted in this output:

Uncaught TypeError: Unsupported operand types: string * string in  
// Converting with intval doesn't work, it returns values ​​as 0.

But I expected this output instead:

3

PHP Version

PHP 8.0.1

Operating System

Microsoft Windows 10 Home [10.0.19043]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions