'How to attach a string on php variable [duplicate]

I am trying to attach a string on php variable this is my code

if ($tipy = "2"){
        $username = "dr_" + $username;
    }

and output to be dr_James

But this doesnt work gives me result as 0.

php


Solution 1:[1]

You should use a dot.

if ($tipy = "2"){
        $username = "dr_" . $username;
    }

See php documentation https://www.php.net/manual/de/language.operators.string.php

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1