How do i join/combine/merge PHP variable with a text?

Discussion in 'PHP' started by postcd, May 7, 2017.

  1. #1
    Hello,

    i have this PHP code:
    this line will cause this command be executed: /usr/sbin/vzctl set 1234 --hostname lkmjfkgkl --save

    And i need the command to be different: /usr/sbin/vzctl set 1234 --hostname lkmjfkgkl.host.name --save

    So here i am looking on how to modify above mentioned line of php code.

    Please how can i join $this->main->hostname with .host.name ?

    I tried:

    but do not think it works

    Please which code to use so i merge above mentioned variable with text ".host.name" so it is merged without any spaces?
     
    postcd, May 7, 2017 IP
  2. GameO.Over

    GameO.Over Active Member

    Messages:
    45
    Likes Received:
    7
    Best Answers:
    1
    Trophy Points:
    65
    #2
    If I am understanding correctly, you want to append 'host.name' string on to a variable?

    If so, you would use a full stop/dot

    e.g.

    $this->main->hostname . "host.name"
    Code (markup):
    Hope this helps :)
     
    GameO.Over, May 7, 2017 IP
  3. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #3
    Like this:

    lxshell_return("/usr/sbin/vzctl", "set", $this->main->vpsid, "--hostname", $this->main->hostname.".host.name", "--save");
     
    JEET, May 8, 2017 IP
  4. postcd

    postcd Well-Known Member

    Messages:
    1,043
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    190
    #4
    Thank You both. This one also works:
    lxshell_return("/usr/sbin/vzctl", "set", $this->main->vpsid, "--hostname", "{$this->main->hostname}.host.name", "--save");
     
    postcd, May 13, 2017 IP