Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shahr's avatar
Level 10

Unsupported operand types: string + int

Controller

    session()->remove('variableSession');
    session()->put('variableSession', request('variable'));
    dd(request('variable'+2))
0 likes
1 reply
LaryAI's avatar
Level 58

The issue in the code is with the line dd(request('variable'+2)). Here, the + operator is trying to concatenate a string ('variable') with an integer (2), which is not supported.

To fix this, you need to concatenate the string and integer values separately before passing it to the request() function. Here's the corrected code:

session()->remove('variableSession');
session()->put('variableSession', request('variable'));
dd(request('variable' . 2));

Note the use of the . operator to concatenate the string and integer values.

Please or to participate in this conversation.