Search code examples
phprequire-once

Multiple function execution with require_once


I have a MVC and I have a function: updateVisitor()

This function is called in visitors.php

And visitors.php is included once time with require_one

But the function is being executed three times, any idea? Is there any php debugger to see where are the functions being called from?

I can't code because it's very huge and I resume it very well


Solution

  • I suggest adding a call to debug_print_backtrace at the beginning of your function:

    debug_print_backtrace(0, 3);
    

    It will tell you where the function was called from.

    If it prints too many lines, you can limit that by passing a parameter:

    debug_print_backtrace(0, 3); // would print only 3 lines at each call