Q:

How to combine two strings in PHP

0

How to combine two strings in PHP

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Use the PHP Concatenation Operator

You can use the PHP concatenation operator (.) to combine or join two strings together in PHP. This operator is specifically designed for strings. Let's see how it works:

<?php
$str1 = 'Hello';
$str2 = 'World!';
$new_str = $str1 . ' ' . $str2;
echo $new_str; // Outputs: Hello World!
?>

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

PHP  and MySQL Frequently Asked Questions

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
How to convert a string to lowercase in PHP... >>
<< How to split a string into an array in PHP...