Sunday, 9 June 2013

WORKING WITH STRINGS

In this post I will be explaining how to declare a string variable, how to assign it a value and how to concatenate two or more strings in php using a period (.).
SOURCE CODE # 1
/*Assigning values to variables and then printing them */
/*********************************************************/
<html>
                <head>
                                <title>String Assignment</title>
                </head>
               
                <body>
                <?php
                                $str1="WORLD";
                                $str2="Liladhar";
                                echo "Hello {$str1} <br /> and Hello {$str2}";
                ?>
                </body>
</html>
/*********************************************************/

SOURCE CODE # 2
/* Concatenation strings */
/*************************************************************/
<html>
                <head>
                                <title>String concatenation</title>
                </head>
               
                <body>
                <?php
                                $str1="Lavish";
                                $str2="Mahaveer ";

                                $str3=$str1." and ".$str2;
                                echo $str3;
                ?>
                </body>
</html>

/***********************************************************/

No comments:

Post a Comment