Write a program in PHP to concatenate strings

in WORLD OF XPILAR2 months ago

coding.jpg

Problem: Write a program in PHP to concatenate strings & shows results on computer screen


Code

<!DOCTYPE html>
            <!Write a program in PHP to to concatenate strings & shows results on computer screen>
            <html>
            <body>
            
            <?php
            //php code starting from here
            
            
            //Concatenation of strings
            //using dot(.) operator 
            
            $string_01; $string_02; $string_03; $string_04; $string_05; $string_06; $string_07; $string_08; $result_string; //string variables declaration
            
            //Assign values to all string variables
            $string_01 = "Johny Johny <br>";
            $string_02 = "(Yes Papa) <br>";
            $string_03 = "Eating sugar? <br>";
            $string_04 = "(No, papa) <br>";
            $string_05 = "Telling lies? <br>";
            $string_06 = "(No, papa) <br>";
            $string_07 = "Open your mouth <br>";
            $string_08 = "(Ah, ah, ah!)";
            
            //Concatenation now
            $result_string = $string_01 . $string_02 . $string_03 . $string_04 . $string_05 . $string_06 . $string_07 . $string_08;
            
            print $result_string; //shows concatenated strings on computer display
            
            
            
            //end of php code
            ?> 
            
            </body>
            </html>


Output

Johny Johny  
(Yes Papa)  
Eating sugar?  
(No, papa)  
Telling lies?  
(No, papa)  
Open your mouth  
(Ah, ah, ah!)


Do it yourself on online PHP compiler: https://onecompiler.com/php

Or, download PHP ver 8.0
Download php Windows 7, 8, 8.1 and Windows 10 (32-64 bit)

Tomorrow I'll post another php problem with solution.
Have a nice day.
Thank you very much.