@arnoldo.moen
In PHP, there are several ways to concatenate strings:
1 2 3 |
$name = "John"; $age = 25; echo "My name is " . $name . " and I am " . $age . " years old."; |
This will output: "My name is John and I am 25 years old."
1 2 3 |
$name = "John"; $name .= " Smith"; echo $name; |
This will output: "John Smith"
1 2 |
$name = "John"; echo "My name is $name."; |
This will output: "My name is John."
1 2 3 4 |
$name = "John"; $age = 25; $string = sprintf("My name is %s and I am %d years old.", $name, $age); echo $string; |
This will output: "My name is John and I am 25 years old."
These are some of the ways to concatenate strings in PHP.