String concatenation in PHP

后端 未结 2 1052
陌清茗
陌清茗 2021-01-20 00:59

Is it possible to send some text message with an echo?

I\'m looking for something like: if($xml) echo $xml+\"hello world;

This is my PHP:

相关标签:
2条回答
  • 2021-01-20 01:53

    Use . instead of + to concatenate in PHP.

    if($xml) { echo $xml . "hello world"; }

    0 讨论(0)
  • 2021-01-20 02:00

    You can use .= to append a string to a variable:

    $xml .= 'Hello World';
    

    If you just want to echo $xml followed by "Hello World", why not:

    if ($xml) {
      echo $xml;
      echo 'Hello World';
    }
    
    0 讨论(0)
提交回复
热议问题