尝试将HTML注入PHP代码以允许在我的网站上创建动态共享链接。
我尝试了以下代码,但导致错误
<?php
// Program to display URL of current page.
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
$link = "https";
else
$link = "http";
// Here append the common URL characters.
$link .= "://";
// Append the host(domain name, ip) to the URL.
$link .= $_SERVER['HTTP_HOST'];
// Append the requested resource location to the URL
$link .= $_SERVER['REQUEST_URI'];
?>
<center><a href="https://www.facebook.com/sharer/sharer.php?
<?php echo $link; ?>
">Facebook</center>
我在第20行收到一条错误消息,提示致命错误语法错误,意外的是<<,期望在第20行出现文件结尾
答案 0 :(得分:0)
似乎代码格式不正确,或者您有
<center>
<a href="https://www.facebook.com/sharer/sharer.php?<?php echo $link; ?>">Facebook</a>
</center>