Forum Moderators: coopster

Message Too Old, No Replies

Server's retrieval order using require and get file

require, get file

         

Minuteman

10:11 pm on May 4, 2007 (gmt 0)

10+ Year Member



The following is on one page named template.html

23 echo 'affiliate num in template = ', $affiliate_num;
24 $aff_name = affiliateName($affiliate_num);

the function affiliateName(} is declared in a page named incl_yo_func.php

the first two lines of code I posted above produces this error

affiliate num in template = 2
Fatal error: Call to undefined function: affiliatename() in http://example.com/link_exchange/index.php/ on line 24

The call it is referring to, the page it says it is happening on, and the line number are all wrong since the call is occuring at those lines I entered above on the template page.

On the index.php page, where it says the error is occuring, I am using first a require --

7 require('incl_yo_func.php');
which is defining the function into the index page three at line 7 . At least I always thought it declares it then and there

Then, in the following line 17 the file_get_contents fuction loads that template.html page that is the one actually calling the function
17 $template = file_get_contents('template.html');

This is from an open source script which I have done quite a bit of work to and I really have never used that file_get_contents () function before. I think everything else about my code is ok so does this get file have some twists and turns that would cause this type of problem?

The file_get_contents is well after the function get defined?

[edited by: Minuteman at 10:13 pm (utc) on May 4, 2007]

[edited by: eelixduppy at 11:07 pm (utc) on May 4, 2007]
[edit reason] example.com [/edit]

dreamcatcher

8:43 pm on May 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Minuteman,

When you call the file_get_contents function, this doesn`t work like including a file. ie, any files or functions called do not get passed on to the file you are loading.

Have you tried including the file?

dc