Concatenation of two strings in PHP Last Updated : 16 Sep, 2024 Comments Improve Suggest changes Like Article Like Report In this article, we will concatenate two strings in PHP. There are two string operators. The first is the concatenation operator ('.'), which returns the concatenation of its right and left arguments. The second is the concatenating assignment operator ('.='), which appends the argument on the right side to the argument on the left side. Examples:Input : string1: Hello string2 : World! Output : HelloWorld!Input : string1: geeksfor string2: geeksOutput : geeksforgeeksExample 1: PHP <?php // First String $a = 'Hello'; // Second String $b = 'World!'; // Concatenation Of String $c = $a.$b; // print Concatenate String echo " $c \n"; ?> Output HelloWorld! Time complexity : O(n) Auxiliary Space : O(n)Example 2: PHP <?php // First String $fname = 'John'; // Second String $lname = 'Carter!'; // Concatenation Of String $c = $fname." ".$lname; // print Concatenate String echo " $c \n"; ?> Output John Carter! Time complexity : O(n) Auxiliary Space : O(n)Example 3: PHP <?php // First String $a = 'Hello'; // now $a contains "HelloWorld!" $a .= " World!"; // Print The String $a echo " $a \n"; ?> Output Hello World! Time complexity : O(n) Auxiliary Space : O(n)Example 4: PHP <?php // First String $a = 'Geeksfor'; // Second String $b = "Geeks"; // now $c contains "GeeksforGeeks" $c = "$a{$b}"; // Print The String $c echo " $c \n"; ?> Output GeeksforGeeks Time complexity : O(n) Auxiliary Space : O(n)PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples. Comment More infoAdvertise with us Next Article Concatenation of two strings in PHP A Anivesh Tiwari Follow Improve Article Tags : Misc Strings Web Technologies PHP DSA PHP-string +2 More Practice Tags : MiscStrings Similar Reads PHP | is_string() Function The is_string() function is an inbuilt function in PHP which is used to check whether the given value is a string or not. Syntax: bool is_string( mixed $var ) Parameters: This function accepts one parameter as mentioned above and described below: $var: It contains the value that need to check. Retur 1 min read How to convert an Integer Into a String in PHP ? The PHP strval() function is used to convert an Integer Into a String in PHP. There are many other methods to convert an integer into a string. In this article, we will learn many methods.Table of ContentUsing strval() function.Using Inline variable parsing.Using Explicit Casting.Using sprintf() Fun 3 min read PHP stristr() Function The stristr() function is a built-in function in PHP. It searches for the first occurrence of a string inside another string and displays the portion of the latter starting from the first occurrence of the former in the latter (before if specified). This function is case-insensitive. Syntax : strist 2 min read PHP mb_stristr() Function The mb_stristr() is an inbuilt function in PHP that is used to get the first occurrence of a string within another string. It will check case insensitivity. Syntax:mb_stristr( $haystack, $needle, $before_needle, $encoding = null ): string|falseParameters: This function accepts 4 parameters that are 2 min read PHP String Functions Strings are a fundamental data type in PHP, used to store and manipulate text. PHP provides a wide variety of built-in string functions. These functions perform various operations such as string transformations, character manipulations, encoding and decoding, and formatting, making string handling s 6 min read Like