所以,我有这个PHP变量:
$text = 'Click on this';
echo '< a href="Google.com"> $text < /a>'
如何将"点击此项"作为超链接文本?
到目前为止,输出在HTML中显示为$text。
两个错误:
- 缺少分号
- 变量是而不是内插在单引号内。使用双引号或其他方式将变量放入字符串中
示例:
$text = 'Click on this';
echo "<a href='"Google.com'"> $text </a>";
或
$text = 'Click on this';
echo '<a href="Google.com"> ', $text, ' </a>';
或
$text = 'Click on this';
echo '<a href="Google.com"> ' . $text . ' </a>';
或
$text = 'Click on this';
printf('<a href="Google.com"> %s </a>', $text);