Jay Arya
Jay Arya

Reputation: 51

How can I show php variable details inside an html form which is inside an echo php?

I have a form in which some I have defined some variables in PHP, The question is I need these variables details inside an html which is inside an echo . I don't know what to do as I have tried it.

   <?php $var= "LOVE" ?>
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
 <?php echo "<!DOCTYPE html>
<html>
<head>
<title>Details</title>
</head>
<body>  
<div > <h1> echo $var ;</h1></div>
</body>
</html>";?>
</body>
</html>

Upvotes: 0

Views: 32

Answers (2)

Yuzar Pratama
Yuzar Pratama

Reputation: 21

You just need to write the variable on double quote. Here an example

<?php 
echo "<html>$var</html>"

// OR if one quote
echo '<html>'.$var.'</html>';
?>

Upvotes: 2

Sinto
Sinto

Reputation: 3997

<?php $var= "LOVE"; ?>
<!DOCTYPE html>
<html>
    <head>
        <title>Page Title</title>
    </head>
    <body>
        <?php echo "
        <!DOCTYPE html>
        <html>
            <head>
                <title>Details</title>
            </head>
            <body>
                <div >
                    <h1>".$var."</h1>
                </div>
            </body>
        </html>";?>
    </body>
</html>

There is no need of adding <html>,<body> tags inside another. There is already one above in your code. I do not know why you have used this pattern.

Upvotes: 1

Related Questions