Code a PHP script that will return a valid HTML markup which
Code a PHP script that will return a valid HTML markup which will have a table with the current date time and day in a table with 2 columns and 3 rows.
Write a version of the script above that returns correcly formatted JSON instead of the HTML!
Solution
solution--
<TABLE border=\"1\"
summary=\"This table gives some statistics about fruit
flies: average height and weight, and percentage
with red eyes (for both males and females).\">
<CAPTION><EM>A test table with merged cells</EM></CAPTION>
<TR><TH>Current Date</TH><TH><p id=\"demo\"></p></TH></TR>
<TR><TH>Current Time</TH><TH><p id=\"demo2\"></p></TH></TR>
<TR><TH>Current Day</TH><TH><p id=\"demo3\"></p></TH></TR>
</TABLE>
<script>
var d = new Date();
document.getElementById(\"demo\").innerHTML = d.toDateString();
</script>
<script>
var d = new Date();
document.getElementById(\"demo2\").innerHTML = d.toTimeString();
</script>
<script>
var d = new Date();
var n = d.getDay()
document.getElementById(\"demo3\").innerHTML = n;
</script>
JSON instead of the HTML!
$header = \"Content-Type: application/json\";
header($header);
$date = date(\"M d, Y\");
print json_encode($date);
