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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. 

 

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.