PHP

 Home  Computers & Internet  Web Programming PHP
What is PHP?
Echo
Comments
Variables
Constants
Data Types
number_format()
Character Strings
Mathematical Operators
Comparison Operators
Logical Operators
Joining Strings
explode()
implode()
strtolower()
strtoupper()
strlen()
ucfirst()
ucwords()
strrev()
str_replace()
str_repeat()
trim()
strip_tags()
addslashes()
stripslashes()
strpos()
strrpos()
nl2br()
isset()
unset()
empty()
POST
GET
If Statements
If Else Statements
Elseif Statements
Switch Statements
For Loops
While Loops
Do While Loops
Foreach Loops
File Create
File Open
File Read
File Write
File Delete
fgets()
file_get_contents()
Date & Time
$_SERVER
Sessions
Cookies
Arrays

CONCATENATION: HOW TO JOIN STRINGS IN PHP

It is possible to join strings in PHP and this process is referred to as Concatenation.

Example:

$string1="John";
$string2="Smith";

$joinedString=$string1.$string2;

echo $joinedString;

Notice that we used a . to join the strings. The above will output JohnSmith. Notice that the words JohnSmith have no space in them. To give it a space, do as follows:

$string1="John";
$string2="Smith";
$joinedString=$string1." ".$string2;

echo $joinedString;

The above will now output John Smith.

You can also add to an existing string using .= as follows:

$string ="John";
$string .="Smith";

echo $string;

This will output JohnSmith. To add a space betwen John and Smith,

$string ="John";
$string .=" ";
$string .="Smith";

echo $string;

This will output John Smith. Another way to add a space,

$string ="John";
$string .=" Smith";

echo $string;

This will output John Smith. Note the space before Smith in the second $string.

Home | Privacy Policy | Terms Of Use | Contact Us | Work At Home | Online Jobs | Smart Info | Online Jobs | Data Entry Jobs | Paid Surveys | Info | Info | Typing Jobs | Article Archive | Forum Posting Jobs