default/optional parameters in function
| From: | Chris Lott | Date: | Thu, 04 Jul 2002 01:44:28 +0000 |
| Subject: | default/optional parameters in function | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-105337@lists.php.net to get a copy of this message | ||
I have a function that writes meta tags... if a tag (or tags) is not
specified, then it gets a default value... is there a cleaner way to
do this?
function print_pmeta ($type)
{
if ($type["description"]) {
print '<meta name="description" content="' .
$type["description"]
. '" />';
}
else {
print '<meta name="description" content="generic description"
/>';
}
if ($type["keywords"]) {
print '<meta name="keywords" content="' .
$type["keywords"] . '"
/>';
}
else {
print '<meta name="keywords" content="generic keyword list"
/>';
}
}
print_meta2(array(
"description" => "A Real Description"
));
c