Thursday 11 February 2016

Concatenate two Strings

Code:

<!DOCTYPE html>
<html>
<body>
<center><h1>CONCATENATE TWO STRINGS</h1>
<?php
if (isset($_POST['add']))
{
    $w1=$_POST['word1'];
    $w2=$_POST['word2'];
    $w3=$_POST['word3'];
    $w4=" is a ".$w3." year old person";
    $w5=$w1." ".$w2.$w4;
    echo "<h3>$w5</h3>";
}
?>
<form method="post" action="index.php">
    Firstname: <input type="text" name="word1">
    Lastname: <input type="text" name="word2">
    Age: <input type="text" name="word3">
    <input type="submit" value="Concatenate" name="add">
</form>
</center>
</body>
</html>


Output:

 

No comments:

Post a Comment