我正在将录音室网站从基于Windows的服务器移动到Linux服务器。除了一个使用ASP函数更新新版本的页面之外,它都是html和php。 我一直试图使用" echo"来尝试转换它,但我甚至无法接近正常工作的代码。 这是:
<%
Function PrintRecord(strImage, strAutore, strTitolo, strInfo, strCredits)
dim strRet
strRet = strRet + " <td valign=""top"">"
strRet = strRet + " <div style=""margin-left: 20px""> "
strRet = strRet + " <img src=""pictures_works/" + strImage + """ height=""80"" width=""80"" border=""1"">"
strRet = strRet +" </td>"
strRet = strRet + " <td width=""170px"" valign=""top"">"
strRet = strRet + " <font class=""TestoPiccoloNo"">"
strRet = strRet + " <b>" + strAutore + "</b><br>"
strRet = strRet + " " + strTitolo + "<br>"
strRet = strRet + " " + strInfo + "<br>"
strRet = strRet + "<i>- " + strCredits + " </i>"
strRet = strRet + " </font>"
strRet = strRet + " </div> "
strRet = strRet + " </td>"
PrintRecord = strRet
End Function
%>
以下是我用来更新的代码:
<%=PrintRecord("somepic.jpg","someband","somerecord","somelabel","whodidwhat")%>
任何帮助将不胜感激。 谢谢!
答案 0 :(得分:2)
+
.
$
;
$strRet = $strRet .
可缩短为$strRet .=
""
替换为\"
<?php
function PrintRecord($strImage, $strAutore, $strTitolo, $strInfo, $strCredits) {
$strRet = '';
$strRet .= " <td valign=\"top\">";
$strRet .= " <div style=\"margin-left: 20px\"> ";
// :
// ...similar
// :
$strRet .= " <b>" . $strAutore . "</b><br>"; // example for concatenation
// :
$strRet .= " </div> ";
$strRet .= " </td>";
return $strRet;
}
?>
和
<?php echo PrintRecord("somepic.jpg","someband","somerecord","somelabel","whodidwhat"); ?>
答案 1 :(得分:1)
在PHP中,您可以执行多行字符串。
<?php
function PrintRecord($strImage, $strAutore, $strTitolo, $strInfo, $strCredits){
$strRet = '
<td valign="top">
<div style="margin-left: 20px">
<img src="pictures_works/'.$strImage.'" height="80" width="80" border="1">
</div>
</td>
<td width="170px" valign="top">
<div>
<font class="TestoPiccoloNo">
<b>'.$strAutore.'</b><br>
'.$strTitolo.'<br>
'.$strInfo.'<br>
<i>- '.$strCredits.'</i>
</font>
</div>
</td>';
return $strRet;
}
?>
或通过HEREDOC语法:
<?php
function PrintRecord($strImage, $strAutore, $strTitolo, $strInfo, $strCredits){
$strRet = << EOT
<td valign="top">
<div style="margin-left: 20px">
<img src="pictures_works/{$strImage}" height="80" width="80" border="1">
</div>
</td>
<td width="170px" valign="top">
<div>
<font class="TestoPiccoloNo">
<b>{$strAutore}</b><br>
{$strTitolo}<br>
{$strInfo}<br>
<i>- {$strCredits}</i>
</font>
</div>
</td>
EOT;
return $strRet;
}
?>
并像这样使用它:
<?php echo PrintRecord("somepic.jpg","someband","somerecord","somelabel","whodidwhat");?>
嗯,看起来怎么样?