Fatal error: Cannot redeclare ws_head()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Crashin
Forum Contributor
Posts: 223
Joined: Mon May 06, 2002 3:42 pm
Location: Colorado

Fatal error: Cannot redeclare ws_head()

Post 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.
User avatar
Crashin
Forum Contributor
Posts: 223
Joined: Mon May 06, 2002 3:42 pm
Location: Colorado

Post 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!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply