Pretty source AND html-output (page source) ?
Posted: Mon Mar 23, 2009 10:27 am
Dear all,
I was wondering if anyone could point me to a place going through the subject making both php-source and the html-output (page source).
Lets say I have a these functions:
printCell($contents){
return "<td>" . $contents . "<td>";
}
printLink($contents){
return "<a>" . $contents . "</a>";
}
Performing this action
echo printCell(printLink("Link"));
Results in an output that looks
<td><a>Link</a><td>
I would like it to print something loke this
<td>
[tab]<a>Link</a>
</td>
This would also be ok
<td>
[tab]<a>
[tab][tab]Link
[tab]</a>
</td>
I wonder if this is possible in some easy way?
I thought about using a $indent variable - but somehow it feels awkward to write:
printMainTable($indent){
return
$indent . "<table>" . "\n" .
$indent . "\t <tr>" . "\n" .
$indent . "\t\t <td>Title</td>" . "\n" .
$indent . "\t </tr>" . "\n" .
$indent . "</table>";
}
And the source suddenly turns into code which I would like to prevent.
I was wondering if anyone could point me to a place going through the subject making both php-source and the html-output (page source).
Lets say I have a these functions:
printCell($contents){
return "<td>" . $contents . "<td>";
}
printLink($contents){
return "<a>" . $contents . "</a>";
}
Performing this action
echo printCell(printLink("Link"));
Results in an output that looks
<td><a>Link</a><td>
I would like it to print something loke this
<td>
[tab]<a>Link</a>
</td>
This would also be ok
<td>
[tab]<a>
[tab][tab]Link
[tab]</a>
</td>
I wonder if this is possible in some easy way?
I thought about using a $indent variable - but somehow it feels awkward to write:
printMainTable($indent){
return
$indent . "<table>" . "\n" .
$indent . "\t <tr>" . "\n" .
$indent . "\t\t <td>Title</td>" . "\n" .
$indent . "\t </tr>" . "\n" .
$indent . "</table>";
}
And the source suddenly turns into code which I would like to prevent.