This article mainly introduces the sharing of a PHP definition function code, mainly let everyone familiar with the PHP syntax format and PHP insert HTML code in the way, I hope to give you some help.
Post Code First
The code is as follows:
<?php
function table () {
echo "<table align= ' center ' border= ' 1 ' width= ' cellspacing= ' 0 ';>";
echo "<caption>For ($out =0 $out < $out + +) {
$bgcolor = $out%2 = = 0? "#ffffff": "Green";
$fontcolor = $out%2 = = 0? "#ffffff": "#000000";
echo "<tr bgcolor=". $bgcolor. " > ";
For ($in =0 $in <10; $in + +) {
echo "<td>". ($out *10+ $in). " </td> ";
};
echo "</tr>";
};
echo "</table>";
}
Table ();
?>
This is the code for a PHP-defined function
Tips
1, note the syntax of PHP format
2. Note the way to insert HTML code in PHP
3, use for the time of the loop, pay attention to think clearly, the difference between the external loop and the inside loop