Reputation: 51
I'm in the process of moving a recording studio website from a windows based server to a linux one. It's all html and php except one page that uses an ASP function to update new releases. I've been trying to convert it myself using "echo", but I couldn't get even close to a working code. Here it is:
<%
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
%>
And here's the code I use to update:
<%=PrintRecord("somepic.jpg","someband","somerecord","somelabel","whodidwhat")%>
Any help would be appreciated. Thanks!
Upvotes: 1
Views: 134
Reputation: 1231
In PHP you can do multilines string.
<?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;
}
?>
or by HEREDOC Syntax :
<?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;
}
?>
and use it like this :
<?php echo PrintRecord("somepic.jpg","someband","somerecord","somelabel","whodidwhat");?>
Well, how do it looks ?
Upvotes: 1
Reputation: 3029
+
with a .
$
;
$strRet = $strRet .
can be shortened to $strRet .=
""
with \"
<?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;
}
?>
and
<?php echo PrintRecord("somepic.jpg","someband","somerecord","somelabel","whodidwhat"); ?>
Upvotes: 2