⊗ppPmBsSCS 29 of 447 menu

Spaces When Concatenating Strings in PHP

Let two strings be stored in variables, and when concatenating them, we want to insert a space between them. This is done as follows:

<?php $str1 = 'abc'; $str2 = 'def'; echo $str1 . ' ' . $str2; // outputs 'abc def' ?>

Let there be only one variable:

<?php $str = 'abc'; echo $str . ' ' . 'def'; // outputs 'abc def' ?>

In this case, there is no point in treating the space as a separate line - we'll insert it as part of the second term:

<?php $str = 'abc'; echo $str . ' def'; // outputs 'abc def' ?>

Create a variable with the text 'hello' and a variable with the text 'world'. Using these variables and the string concatenation operation, output the string 'hello world' to the screen.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline