Reputation: 51
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
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
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