PHP Make an HTML table creating it out of PHP functions. <html> <body> <?php fun
ID: 642614 • Letter: P
Question
PHP
Make an HTML table creating it out of PHP functions.
<html>
<body>
<?php function td($name){
" <td>$name</td>";
}
?>
<?php function tr($tr) {
"<tr> td($name) </tr>";
}
?>
<?php function table(){
"<table border=1>";
"$tr";
"</table>";}
?>
td("red");
td("blue");
td("green");
td("purple");
td("pink");
td("white");
td("black"");
td("yellow");
td("orange");
table();
</html>
</body>
I need it to output a table, but when I run it it only lists out the code.
What is wrong, please help.
Explanation / Answer
<html>
<body>
<?php function
td($name){
echo " <td>$name</td>";
}
?>
<?php function tr($tr) {
echo "<tr>". td($name)." </tr>";
}
?>
<?php
function table(){
echo "<table border=1>";
echo "<tr>";
td("red");
td("blue");
td("green");
td("purple");
td("pink");
td("white");
td("black");
td("yellow");
td("orange");
echo "</tr>";
echo "</table>";
}
?>
<?php
table();
?>
</html>
</body>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.