PHP Concatenation
We can display our variables in a meaningful fashion with the use of concatenation. Concatenation makes use of the period (.). Please see the example below which is an example of affixing a value to the end of the variable:
<?php $name = “Marc”; $name .= “Fraser”; ?>
Basically what ‘.=’ is doing is saying use the current value of $name and add “Fraser” to the end of it. If I were to now print $name, it would output “MarcFraser”.
We can also use concatenation to create readable sentences:
<?php $name = “ Marc Fraser”; $age = 16; print “We would like to welcome you,” . $name . “, age” . $age . “ to our website!”; ?>
This will output “We would like to welcome you, Marc Fraser, age 16 to our website!”. To do this, we close the string (close quotation mark) and add our period, which tells the server that we wish to begin parsing PHP again. When we want to stop parsing PHP we add a period and then begin our string again (quotation mark).
Introduction to PHP, the basics. [Full Article]
Introductions
Article Scope
This article aims to express the basics, which a beginner should consider when learning PHP. It will explain how to create a very basic PHP page that will contain fundamental commands to PHP beginners.
For this article, I will be using XAMPP to execute my PHP code – this is free to download and is great, especially if you do not have a web server with PHP installed.