读书人

求准确写法

发布时间: 2012-08-03 00:12:14 作者: rapoo

求正确写法
直接看代码:

PHP code
    while ($row=mysql_fetch_row($result))    {      for ($i=0; $i<mysql_num_fields($result); $i++ )      {        echo '<a href="../products/index.php?pclass=$row[$i]">';//这一行,plass=后面应该怎么写才符合规范?        echo "$row[$i]";        echo '</a>';      }    }


谢谢

[解决办法]
echo "<a href='../products/index.php?pclass=$row[$i]'>";
[解决办法]
Note: 不像双引号 和heredoc语法结构, 在单引号字符串中的变量 和特殊含义的字符将 不会 被替换。
http://www.php.net/manual/zh/language.types.string.php
[解决办法]
echo "<a href='../products/index.php?pclass={$row[$i]}'>";

读书人网 >PHP

热点推荐