Weird function-problem

Discussion in 'PHP' started by PoPSiCLe, May 26, 2009.

  1. #1
    Okay. I have a file called global_functions.php, where I define the main functions used on the site. This works fine.

    In one of these functions, there is a call for "include('admin_modules.php');" which also works fine.

    In the admin_modules.php-file, there is a call to a function, publish_info(); <- this one does NOT work when the function is declared in the admin_modules.php-file.

    If I move the publish_info() function to the global_functions.php, it works just fine.

    While it's located in the admin_modules.php-file, I get a "call to undefined function".

    Anyone know why this happens? Shouldn't a function declared in the end of a file work just fine?

    And the function itself isn't very complicated - right now it's just an echo-statement, for testing purposes.

    Nevermind! I found the problem, and as usual it was plain and simple user-error. There was an include-file present that overwrote a value, thus making the function invalid. Fixed now :)
     
    PoPSiCLe, May 26, 2009 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Are you positive that the file is being included properly? If you haven't tried it, I would use require, and see if an error is thrown.
     
    jestep, May 26, 2009 IP
  3. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #3
    The file itself was included properly - the file contained other info that showed up when I removed the function. So that wasn't the problem. To me, it seemed the problem was an object-call in the original function, which used a $user-variable, which got overwritten because of another include in the parent function. Removed the include from the parent function, and everything works as it's supposed to do :)
     
    PoPSiCLe, May 26, 2009 IP