What are String variables?

String variable is a variable that can store a series of characters.

For example

$string1 = “Hello”;
$string2 = “World”;
echo $string1. “”. $string2;

To concatenate string we use the operator.

Keep in mind that the echo command above can be made longer as follows:
echo $string1;
threw out ” “;
echo $string2;

As one exercises, we can summarize the output of multiple variables in a single command.
When a string enclosed in double quotes contains a variable inside it, it is treated as such, therefore its content will be used for storage.

$day = 10;
$date = “Today is $day”;
echo $date;
The display shows: Today is 10

That is, in the chain, the name of the variable $day is replaced, with the content of the same.

A string can be defined with single quotes (but it is important to note that variables are not substituted if we use single quotes):

$name = ‘juan carlos’;

 

This article was written by admin

Leave a Reply