Hello. Question about passing existing objects as parameters to functions. Example.
Code: Select all
/* create datbase connection */
$db = new db();
function getPageHeader($title, $db) {
include('header.php');
}
$title = "this is a page";
getPageHeader($title);
/*then the rest of the page */
Now there are like 20 pages that calls the getPageHeader function as the title varies from page to page. However the DB object is constant so is there a way to set it as a default value in the getPageHeader function instead of having to do " getPageHeader($title, $db); " on all the pages.
thanks in advance
/Daniel