Define section name at the top of your function:
PHP Code:
function getSectionName($dbc, $slug){
$sectionName="";
// if, (buts and maybes) {
// do your stuff here
// else chuck silent errors
}
// then no matter what happens:
return $sectionName;
}
You could develop that idea further if you wanted:
PHP Code:
function getSectionName($dbc, $slug, $default = ''){
$sectionName= $default;
// do your stuff here
// else chuck silent errors
// then no matter what:
return $sectionName;
}
This would leave you open to using it like:
PHP Code:
echo sectionName($foo,$bar);
// OR adding something slightly more helpful
echo sectionName($foo,$bar, $siteName);
The cost is that you have an extra [optional] argument going into your function, some might find that ugly.
Bookmarks