PHP中的字符串连接 [英] String concatenation in PHP

查看:63
本文介绍了PHP中的字符串连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以发送带有回声的文本消息?

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

我正在寻找类似的东西: if($ xml)echo $ xml + hello world;

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

这是我的PHP:

[...]curl_setopt($curl, CURLOPT_URL, 'http://api.imgur.com/2/upload.xml');
    curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $pvars);

    $xml = curl_exec($curl);

    curl_close ($curl);
 if($xml) echo $xml; 
?>


推荐答案

您可以使用。= 将字符串附加到变量:

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

$xml .= 'Hello World';

如果您只想回显$ xml后跟 Hello World,为什么不呢?

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

if ($xml) {
  echo $xml;
  echo 'Hello World';
}

这篇关于PHP中的字符串连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆