- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Concatenation of two strings in PHP program
To concatenate two strings in PHP, the code is as follows −
Example
<?php $a = 1.967; $b = 1.969; $res = $a." and ".$b; echo " $res
"; if((round($a, 2)) == (round($b, 2))) { echo "
Both the values are equal!"; } else { echo "
Both the values aren\'t equal"; } ?>
Output
This will produce the following output−
1.967 and 1.969 Both the values are equal!
Example
Let us now see another example −
<?php $val1 = 'Jack'; $val2 = 'Sparrow'; echo "First Name = $val1
"; echo "Second Name = $val2
"; $res = $val1.$val2; echo "Concatenation = $res
"; ?>
Output
This will produce the following output−
First Name = Jack Second Name = Sparrow Concatenation = JackSparrow
- Related Articles
- Concatenation of two strings in PHP\n
- Concatenation of Strings in Java
- Smart concatenation of strings in JavaScript
- Concatenation of strings in Lua programming
- Check if concatenation of two strings is balanced or not in Python
- C++ program to get length of strings, perform concatenation and swap characters
- Concatenation of two String Tuples in Python
- Program to append two given strings such that, if the concatenation creates a double character then omit one of the characters - JavaScript
- Program to Compare two strings in Java
- Find uncommon characters of the two strings in C++ Program
- Program to find largest merge of two strings in Python
- C++ Program to Concatenate Two Strings
- Java Program to Compare Two Strings
- C program to swap two strings
- Program to add two binary strings in C++

Advertisements