join two strings in php

To join two strings (concatenate) in PHP, you can use the concatenation operator .. Here's an example:

main.php
$string1 = "Hello";
$string2 = "world!";
$joined_string = $string1 . " " . $string2; // output: "Hello world!"
111 chars
4 lines

In this example, we first declared two variables $string1 and $string2 and assigned them the values "Hello" and "world!". Then we used the . operator to join them together with a space in between, resulting in the final string of "Hello world!".

related categories

gistlibby LogSnag