Jump to content

newbie question about include file


Drew_13

Recommended Posts

hey, i have a newb question about a php environment. i set up a file called html.inc, and i am trying to put multiple functions in it, to use on my index page. however i keep getting an error.

 

here's what my html.inc looks like:

<?

/*
* Created on Feb 21, 2008
*
*/

function header()
{
?>
<html>
<head>
</head>
<body>
<?
}

function footer()
{
?>
</body>
</html>
<?
}
?>

 

and this is what i have regarding this file in my index.php:

 

<?php
require("include/html.inc");

header(1);

footer();
?>

 

 

and it gives me this error:

Fatal error: Call to undefined function footer() in C:\Program Files\php_workspace\index.php on line 9

 

 

i would like to be able to use more than even just two functions in this file, and perhaps have other include files in the future. do you know what would cause this error? thanks alot!

Link to comment
Share on other sites

The file name and extension used for include/require files does not matter (except that the raw content of files not ending in .php can be seen by browsing to them, assuming you know or can guess the file name.)

 

The original problem is that the included/required file is not using full php open tags <?php so the content is not being parsed as php code. The main file is using full <?php tags. Drew_13, you need to be consistent and always use full <?php tags.

 

The next problem is that header() is a built in php function and you cannot name a user written function the same.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.