Page 1 of 1

Fatal error: Cannot redeclare ws_head()

Posted: Tue Oct 01, 2002 11:41 am
by Crashin
Hidee-ho, all! Here's the deal...

I've set up a site search on a corporate website redesign I'm working on. The search I'm using creates the results page by calling two other pages, header.php and footer.php, and sticking the results in between, basically. Everything is working beautifully except for this error I'm getting at the bottom of the results list:

Fatal error: Cannot redeclare ws_head() in /u/web/chec36/development/website/functions/ws_functions.php on line 13

The function it is referring to is a function I use in all of the site's pages to build the logo, navigation, etc. It is being called in the header.php file. It's very simple:

Code: Select all

<?php
	require("/www729/web/chec36/development/website/functions/ws_functions.php");
	
	$title = "CheckMark Software, Inc. - Accounting and Payroll made easy";
	ws_head($title, $title);
	ws_middle();
?>
What up with that error? Is this enough info. about the problem? Thanks!

Edit: I've done some more testing, trying include_once, require_once, and checking to make sure that I haven't declared the function more than once. Still getting the same problem.

Posted: Tue Oct 01, 2002 2:25 pm
by Crashin
Nevermind...got it. The footer.php file was also including the ws_functions.php file, which was the problem. Once I removed that line, all was good!

Posted: Wed Oct 02, 2002 2:27 am
by twigletmac
You can use include_once() or require_once() to include function or class files. Unlike require() or include() these functions won't try and include the file again if they've already done it once preventing the 'cannot redeclare function' errors.

Mac