Amin Hijaz Amin Hijaz - 8 months ago 30
PHP Question

How to use put var between double quotes

I want to use this code

$person = ""$steamid" "" "abcdefghijklmnopqrstu" "ce"\n";

for example if
= STEAM_0:0:123456

the outpur should look like this

"STEAM_0:0:123456" "" "abcdefghijklmnopqrstu" "ce"

I hope someone can correct my PHP code

$person = ""$steamid" "" "abcdefghijklmnopqrstu" "ce"\n";


Use . (dot) between variables to join them.


$var = $somevar . "sometext" . $anothervar . "and it works" . "you can add more text";

Spaces doesn't matter between variables and quoted text.


There are two string operators. The first is the concatenation operator ('.'), which returns the concatenation of its right and left arguments. The second is the concatenating assignment operator ('.='), which appends the argument on the right side to the argument on the left side.

    $a = "Hello ";
    $b = $a . "World!"; // now $b contains "Hello World!"

    $a = "Hello ";
    $a .= "World!";     // now $a contains "Hello World!"

Here is detailed explanation of same thing from php manual

And to answer your question, since you need to output these -> " " , you need to use single quotation marks in code. So, your code would look like this:


    $steam = '"STEAM_0:0:123456"'; 
    echo $person = $steam . ' ""' .' "abcdefghijklmnopqrstu" "ce"';


Here are screenshots: