user2267055
user2267055

Reputation: 43

php Fatal error: Call to undefined function when is already defined in a different file

I have home page and a seperate file display_functions.php from where I am calling function file home.php

file display_functions.php 
html_header($title)
{
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xHTML1/DTD/xHTML1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="https://www.facebook.com/2008/fbml">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 

<title><?php echo $title;?></title>
<link href="home_style.css" rel="stylesheet" type="text/css" />
</head>;
}


html_footer()
{

}

getting error: html_header($title) { ; } html_footer() { } ( ! ) SCREAM: Error suppression ignored for ( ! ) Fatal error: Call to undefined function html_header() need help

Upvotes: 0

Views: 467

Answers (2)

loncool
loncool

Reputation: 11

your code is error.. You should wrapped the code which inside the html_header function whith echo, and html_header() is a function, so you need add a function keyword before it.

Upvotes: 1

skytreader
skytreader

Reputation: 11707

That error happens because you put HTML tags directly in your PHP source (it's a syntax error). I guess you meant using echo on them?

And, in general, saving yourself from boilerplate code in this manner isn't a good idea. Better create templates or use an MVC framework.

Upvotes: 0

Related Questions