You can nest functions, but the internal function is not seen until the enclosing function is called.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lang="EN">
<head>
<title>PHP</title>
<meta Name="Author" Content="Hann So">
</head>
<body>
<p>
<?php
function what_fruits($type ="grapes")
{
echo "What fruits will we get?<br />";
function fruits($type ="grapes")
{
echo "We serve $type for dinner.<br />";
}
}
what_fruits();
fruits();
fruits(strawberries);
?>
</p>
</body>
</html>
|