1
<?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>
4

5 回答 5

2

在 PHP 中,变量不使用单引号字符串进行插值;如果您想要该功能,则需要执行以下操作:

echo "Hello $name";

代替

echo 'Hello $name';

如果您想使用单引号,请连接您的字符串,如下所示:

echo 'Hello ' . $name;

于 2013-02-20T05:23:11.343 回答
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> ';
   }
   ?>
于 2013-02-20T06:00:59.953 回答
0

用这个

echo '<div class="result"My blank is under</div> <div class="green">' . $lname . '</div> ';} 
于 2013-02-20T05:23:40.450 回答
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 }  ?>
于 2013-02-20T05:25:34.350 回答
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 获胜者 uno me pase mas de un resultado a la vez o si se puede repetir infinidad de veces

于 2015-06-09T12:57:28.390 回答