简体   繁体   English

如何在echo php内的html表单内显示php变量详细信息?

[英]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 . 我有一种形式,其中一些已经在PHP中定义了一些变量,问题是我需要在echo中的html内包含这些变量的详细信息。 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>

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>';
?>
<?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. 无需在另一个标签内添加<html>,<body>标签。 There is already one above in your code. 您的代码中上面已经有一个。 I do not know why you have used this pattern. 我不知道您为什么使用这种模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM