将 ASP 函数转换为 PHP
Converting an ASP function to PHP
我正在将录音室网站从基于 windows 的服务器迁移到 linux 的服务器。全部是 html 和 php,只有一页使用 ASP 功能来更新新版本。
我一直在尝试使用 "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")%>
如有任何帮助,我们将不胜感激。
谢谢!
- 将每个
+
替换为 .
- 前缀变量
$
- 以
;
结束行
$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"); ?>
在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");?>
嗯,看起来怎么样?
我正在将录音室网站从基于 windows 的服务器迁移到 linux 的服务器。全部是 html 和 php,只有一页使用 ASP 功能来更新新版本。 我一直在尝试使用 "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")%>
如有任何帮助,我们将不胜感激。 谢谢!
- 将每个
+
替换为.
- 前缀变量
$
- 以
;
结束行
$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"); ?>
在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");?>
嗯,看起来怎么样?