String concatenation in PHP

Can I send a text message with an echo?

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

This is my 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; ?> 
+4
source share
2 answers

You can use .= To add a string to a variable:

 $xml .= 'Hello World'; 

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

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

Use . instead of + for concatenation in PHP.

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

+3
source

All Articles