String and variable concatenation in php

后端 未结 6 899
自闭症患者
自闭症患者 2021-01-13 07:01

I am new to PHP and I want to concatenate a string with a variable without any space. I am using a variable $var and a string which is given below.

         


        
相关标签:
6条回答
  • 2021-01-13 07:34

    use

    $var2 = "Name\Branch\".$var;
    
    0 讨论(0)
  • 2021-01-13 07:39

    Space is there, because you entered it ;)

    Use examples:

    $var2 = "Name\Branch\\$var";
    $var2 = "Name\Branch\\" . $var;
    $var2 = 'Name\Branch\\' . $var;
    $var2 = "Name\Branch\\{$var}";
    $var2 = trim("Name\Branch\ ") . $var;
    
    0 讨论(0)
  • 2021-01-13 07:43

    Please try below code : concatenation $var and $str using dot(.)

     $var = 'variable';
     $newvar = "Name\\Branch\\".$var
    
    0 讨论(0)
  • 2021-01-13 07:50

    You can use { } to use variable's value in a string.

    $result = "Name\Branch\\{$var}";
    
    0 讨论(0)
  • 2021-01-13 07:51

    Use . for concatenations:

    $var2 = "Name\\branch\\".$var;
    

    Refer to the PHP manual.

    0 讨论(0)
  • 2021-01-13 07:54

    this will help u

    $var1 = 'text';
    $var2 = "Name\branch\".$var1;
    

    o/p: Name\branch\text

    0 讨论(0)
提交回复
热议问题