I am using php to write an online classifieds site w/ about a dozen categories. I wrote one copy of the listings page and the ad view page and the submit ad page, etc. Then I just pass the category to those scripts and include("$cat.inc"). Each categories include file includes functions for listing() and form(), etc.

This works great, except now I am writing a search script where I want to call the listing function from multiple categories in the same script. So, basically I need to include one category's include file, call the listing() function then include another category's include file and call its listing() function. Of course, when I include the second category's include file then I get a function redefine error.

I tried include()'ing the file in a function, hoping to limit its scope, but that didn't seem to work. Any ideas?

Thanks,
Jonathan

    try "include_once" instead "include"
    (just for .inc files - where you have defined functions)

    PM

      Well, the problem is that I want to redefine those functions. Its my understanding that include_once just prevents the same file from being included more than once. I'm actually not including the same file more than once, just the same function and I'm doing it on purpose.

        Write a Reply...