包括PHP变量作为超链接项


Including PHP variables as hyperlink item

我面临的问题是创建一个超链接,其中有两个php变量在链接:

       <a href="http://www.mydomain.com/wp-content/uploads/file_uploads/'.$userID.'/'.$Thefile">'.pathinfo($Thefile, PATHINFO_FILENAME) .'</a></td>';

显示错误。

请在这方面帮助我。

你没有给我太多线索。但是试试这个:

<?php
  echo '<a href="http://www.mydomain.com/wp-content/uploads/file_uploads/'.$userID.'/'.$Thefile.'">'.pathinfo($Thefile, PATHINFO_FILENAME) .'</a></td>';
?>

您在$Thefile之后漏了.'

这些引号可能会很棘手

<?php
echo "<a href='"http://www.mydomain.com/wp-content/uploads/file_uploads/".$userID."/".$Thefile."'">".pathinfo($Thefile, PATHINFO_FILENAME)."</a>";
?>

我知道人们会因为我没有使用正确的html引号而生气,但是这个答案是最漂亮的

$pathInfo = pathinfo($Thefile, PATHINFO_FILENAME);
echo "<a href='http://www.mydomain.com/wp-content/uploads/file_uploads/$userID/$Thefile'>$pathInfo</a>";