【问题标题】:Value of variable not getting passed into the echo statement变量的值没有被传递到 echo 语句中
【发布时间】:2015-03-27 05:19:43
【问题描述】:

我正在使用变量传递 href 属性中的值,但变量的值没有被传递,要么它什么都不传递,要么变量名本身传递。

如何使用引号和变量来成功传递变量的值? 下面是代码:

<?php
for ($x = 0; $x < $count; $x++)
  {

    $html= '<a href="productTest.php?pro='".$out[$x][2]."'>'.$out[$x][0].'</a>: added on-'.date('M j Y g:i A', strtotime($out[$x][1]));
    //<a href="productDisplay.php">Products</a>
    echo $html;

    echo "<br><br>";

  }
  ?>

【问题讨论】:

    标签: php


    【解决方案1】:

    这应该可行:

    <?php
    for ($x = 0; $x < $count; $x++)
      {
    
        $html= '<a href="productTest.php?pro='.$out[$x][2].'">'.$out[$x][0].'</a>: added on-'.date('M j Y g:i A', strtotime($out[$x][1]));
        //<a href="productDisplay.php">Products</a>
        echo $html;
    
        echo "<br><br>";
    
      }
      ?>
    

    我用'.$out[$x][2].'替换了'".$out[$x][2]."'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-10
      • 2014-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多