PHP String Variable

PHP string variable is variable that is used contains text or characters. In this lesson we are going to learn how to store a string in a variable and use a string directly into a function.

Let’s see some example of storing a string in a variable and output it in our browser using the echo clause.

<?php
 $greetings="Hi guys!";
 echo $greetings;
 ?>

The output will be:

Hi guys!

Concatenation Operator

Concatenation Operator is a operator used to join two or more characters.

The symbol of Concatenation Operator in PHP is a period (.).

Here is the example of putting two strings using the Concatenation Operator:

<?php
 $text1="Hi guys!";
 $text2="How are you?";
 echo $text1 . " " . $text2;
 ?>

The output will be:

Hi guys! How are you?

, , , , , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.