www.webdeveloper.com
Results 1 to 3 of 3

Thread: file getting written wrongly

  1. #1
    Join Date
    Jan 2009
    Posts
    15

    Exclamation file getting written wrongly

    I use a simple file counter to track how many times each function
    in a script of mine gets executed. so I have two file
    to track how many times each function is called/executed.
    The script is written is such a way that
    one function will be executed once only
    after the other function is executed
    atleast three times.(after page receives 3 hits)
    So content of one file will be always higher than the other file.
    But sometimes the content of the second file
    is more than the other file
    What might be the problem ?

    Is there any other way to track how many times a function is called ?

  2. #2
    Join Date
    Jan 2009
    Posts
    3,346
    Can you post some code? It sounds like a logic error to me.

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,923
    As far as tracking function usage, I might do:
    PHP Code:
    function_a()
    {
       isset(
    $GLOBALS['function_count'][__FUNCTION__]) ? 
          
    $GLOBALS['function_count'][__FUNCTION__]) + 1;
       
    // rest of function definition . . .
    }
    // end of script:
    $log __FILE__ " (" date('Y-m-d H:i:s') . "): ";
    foreach(
    $GLOBALS['function_count'] as $function => $count)
    {
       
    $log .= $function $count "; ";
    }
    error_log(rtrim($log" ;")); 
    ?>
    [/php]
    Then just check the PHP error log for usage (or specify a separate file in the call to error_log()).
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles