Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 25th, 2012, 01:04 PM
Registered User
 
Join Date: Jun 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Exclamation Fatal error: Cannot redeclare header()

Hi everyone, I have a problem to call external functions.
I wrote this:
Code:
<?php 
function header(){
?>
<!DOCTYPE html>
<html>
<head>
</head>
<?php
}
?>
in a php file named header.php
in the index page i've included the function in this way:
Code:
<?php 
include_once 'tiles/header.php';

header();
?>
when I watch this page on the browser I get this error:
Code:
Fatal error: Cannot redeclare header() in /var/www/vhosts/../header.php on line 9
any suggestion on how to solve this?
 
Old June 26th, 2012, 03:51 AM
Registered User
 
Join Date: Jun 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Ok, solved, I just changed the function name from header() to head() and now no problems.
if anyone knows why please post the reason so that I can know at least why...
 
Old June 26th, 2012, 04:03 AM
Friend of Wrox
 
Join Date: May 2011
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts
Default

Greetings,

Because there is already a php function called 'header' and you were creating another one hence the 'cannot redeclare' error.
The Following User Says Thank You to UseLess For This Useful Post:
clinicalbear (June 26th, 2012)
 
Old June 26th, 2012, 04:05 AM
Registered User
 
Join Date: Jun 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default

thank you UseLess, I thought something like this and you confirmed it.





Similar Threads
Thread Thread Starter Forum Replies Last Post
fatal error C1189: #error : WINDOWS.H already included tedkurtz BOOK: Ivor Horton's Beginning Visual C++ 2008 ISBN: 978-0-470-22590-5 1 December 16th, 2009 03:06 PM
FATAL ERROR. Help me please??? steviej1 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 11 February 27th, 2007 08:05 AM
Fatal Error?? dparsons ASP.NET 1.0 and 1.1 Professional 0 December 18th, 2006 01:55 PM
fatal error!!!! Ashleek007 Beginning PHP 6 October 9th, 2004 10:25 AM
Fatal error: singhzubin BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 2 April 11th, 2004 04:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.