<?php $lname = $_POST['lname'];
if ( isset($_POST['lname'] )&& !empty( $_POST['lname'] ) ) {
echo '<div class="result"My blank is under</div> <div class="green"> $lname </div> ';
} else {
echo '<div class="result">Please tell them your</div> <div class="green">last name!</div> ';
}
?>
语法应该是正确的,但是当我将数据输入到我的表单中时,echo语句在绿色类中显示变量名$ lname而不是输入的数据。
我在某个地方忘记了引语还是逃到某个地方?
<style>
.result {
color: #FFF;
display: block;
font-size: 36px;
margin-top: 1px;
margin-before: 5px;
margin-bottom: 0px;
margin-start: 0;
margin-end: 0;
text-align:center;
font-weight: bold; }
.green {
color: #C9FF1F;
display: block;
font-size: 40px;
margin-top: 1px;
margin-before: 5px;
margin-bottom: 0px;
margin-start: 0;
margin-end: 0;
text-align: center;
font-weight: bold;
}
</style>
答案 0 :(得分:2)
在PHP中,变量不使用单引号字符串进行插值;如果你想要这个功能,你需要做这样的事情:
echo "Hello $name";
而不是
echo 'Hello $name';
如果要使用单引号,请连接字符串,如下所示:
echo 'Hello ' . $name;
答案 1 :(得分:2)
User below code, it will solve your problem.
<?php
$lname = $_POST['lname'];
if ( isset($_POST['lname'] ) && !empty( $_POST['lname'] ) ) {
echo '<div class="result">My blank is under </div> <div class="green"> '.$lname.' </div> ';
} else {
echo '<div class="result">Please tell them your</div> <div class="green">last name!</div> ';
}
?>
答案 2 :(得分:0)
使用此
echo '<div class="result"My blank is under</div> <div class="green">' . $lname . '</div> ';}
答案 3 :(得分:0)
试试这个............
<?php $lname = $_POST['lname'];
if ( isset($_POST['lname']) && !empty($_POST['lname'])) { ?>
<div class="result">My blank is under</div> <div class="green"><?php echo $lname ?></div> ';
<?php } else { ?>
<div class="result">Please tell them your</div> <div class="green">last name!</div> ';
<?php } ?>
答案 4 :(得分:0)
<div id="do-info">
<div class=WINER">+ ,0<span id="regalo">0</span> DOMM</div>
</div>
<div id="do-info2">
<div class="WINER2">Mañana DOOM</div>
</div>
OLA BUEN DIA quisiera saber como le puedo hacer para que el winner uno me pase mas de un resultado a la vez o si se puede repetir infinidad de veces