Jump to content

[solved] calling outside functions from the include file?


andr923

Recommended Posts

Hey guys,

 

I'm new to this community and am a musician who's been teaching himself some php to use on his site.

 

My question is kind of straightfoward.  The way my site will work is that every page will 'include' the template.php with the basic structural elements.  What I want to do is create functions in the site pages so that the included file (template.php) can call those functions and input the appropriate content. 

 

I.E. my index.php file contains function image() {}.  a few lines later in the same index.php file i include my template.php.  In the template.php file I want to be able to call on the function "image()".  Is that possible? and how do I do it?

 

Thanks a bunch!

 

if curious this is my work in progress:

 

http://www.andreimatorin.com/new

Give it a try, it does work. A better solution would be to create a "Functions" file and include that in the template.php file, that way you have one place to modify all functions and only need to include one file, template.php.

 

But yes it would work.

sorry i should have mentioned that I did try and it's giving me

 

Fatal error: Call to undefined function: image() in /home/andreima/public_html/new/includes/template.php on line 80

 

the problem with your suggestion to include a functions file is that I am using these functions to determine the content of each page.  I want each page to have the same function names, but their content is actually different. 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.