PHP超链接插入错误


php hyperlink insert error

我无法在php中插入超链接,当我以以下方式插入超链接时,页面变空白:

echo "' &bull; {$row['ntitle']}: <a href='"detail.php?id=' . $row['id'] . ''" class='"style1'">Detail </a>'";

请帮我解决这个问题

您的行包含与引号和双引号的开、闭相关的错误。

这个应该可以完成工作:

echo "&bull; {$row['ntitle']}: <a href='"detail.php?id={$row['id']}'" class='"style1'">Detail </a>";

应该输出如下内容:

• yourTitle: Detail

try this

 echo "&bull; ".$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);

您的字符串引号不正确

试试这个代替你的:

echo ' &bull; '.$row["ntitle"].': <a href="detail.php?id=' . $row["id"] . '" class="style1">Detail </a>';

或者使用printf来避免被大量的引号和concats混淆:

printf(' &bull; %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(" &bull; %s: <a href='"detail.php?id=%s'" class='"style1'">Detail </a>",$row["ntitle"],$row["id"]);
echo $string;