我不能够在PHP中插入超链接时,网页一片空白,当我插入如下的方式的超级链接:PHP的超级链接插入错误
echo "' • {$row['ntitle']}: <a href=\"detail.php?id=' . $row['id'] . '\" class=\"style1\">Detail </a>'";
请帮我解决这个问题
我不能够在PHP中插入超链接时,网页一片空白,当我插入如下的方式的超级链接:PHP的超级链接插入错误
echo "' • {$row['ntitle']}: <a href=\"detail.php?id=' . $row['id'] . '\" class=\"style1\">Detail </a>'";
请帮我解决这个问题
您的行包含与引号和双引号的打开和关闭有关的错误。
这应该做的工作:
echo "• {$row['ntitle']}: <a href=\"detail.php?id={$row['id']}\" class=\"style1\">Detail </a>";
这应该输出类似:
• yourTitle: Detail
试试这个
echo "• ".$row['ntitle']." : <a href=\"detail.php?id='" . $row['id'] . "'\" class=\"style1\">Detail </a>";
您的线路有错误,请使用以下行显示在页面的开头php的适当的错误。
ini_set('display_errors','1');
error_reporting(E_ALL & ~E_NOTICE);
您的字符串是不正确的quotted
试试这个,而不是你的:
echo ' • '.$row["ntitle"].': <a href="detail.php?id=' . $row["id"] . '" class="style1">Detail </a>';
或使用printf避免被大量引用和concats困惑:
printf(' • %s: <a href="detail.php?id=%s" class="style1">Detail </a>', $row["ntitle"], $row["id"]);
肯定会在http://www.php.net/manual/en/function.error-reporting.php上显示错误/警告/通知。
使用sprintf函数来格式化您的字符串。尝试这个。
$string = sprintf(" • %s: <a href=\"detail.php?id=%s\" class=\"style1\">Detail </a>",$row["ntitle"],$row["id"]);
echo $string;