 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- 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
Advertisements
 