Results 1 to 3 of 3
  1. #1
    Join Date
    May 2009
    Posts
    766

    PHP execute function last

    Okay, this is is kind of a weird one. I'm working on a site where pretty much every page is /index.php, and then different form vars trigger different include files. I'm tracking user messages, warnings, etc. in a global var and then the last thing that index.php does is populate a popup div if there are any messages to display. Works great.

    Problem is that a lot of page executions are called by ajax and index.php doesn't get called again. I've got a separate function which will populate and show the message popUp in an ajax execution, but the problem is calling it once at the end of the script execution. It's handled in a normal request since index.php is called and I can just slap it at the end. In an XML request, however, there could be any variety of pages being called, and I'm trying to avoid having to fire off this function at the end of every one of them. I have a common functions file that is included on every page already, so that seems like the best candidate, but the trick is getting it to fire at the end.

    I've attempting this:
    PHP Code:
    pcntl_signal(SIGTERM"showAjaxMsg"); 
    but it would appear that our version of PHP was not compiled with --enable-pcntl. I'm running on a corporation wide, controlled RPM, so re-compiling is not an option. Anyone have any other ideas to set a function to fire at the end of script execution?

  2. #2
    Join Date
    May 2008
    Location
    Rutherford, NJ
    Posts
    68
    if you have a message/alerts class, put that in its own include file that will be called by any page (index,ajax server, etc) and put it in the class destructor.
    or do it in the javascript.
    Database design and performance optimization, custom PHP scripts, and publicly available resources for developers!
    http://www.zeropride.com

  3. #3
    Join Date
    May 2009
    Posts
    766
    Great idea! I'll give that a shot.

Similar Threads

  1. Replies: 1
    Last Post: 03-15-2006, 02:19 AM
  2. Execute the sql.txt file
    By steveTobb in forum Programming Discussion
    Replies: 2
    Last Post: 12-06-2003, 03:00 PM
  3. Replies: 1
    Last Post: 10-05-2003, 01:23 PM
  4. is it possible to execute ssi in .php?
    By Futuredood in forum Web Hosting Lounge
    Replies: 7
    Last Post: 08-16-2003, 04:47 PM
  5. CGI Post function slow to execute
    By Terry Ames in forum Dedicated Server
    Replies: 0
    Last Post: 01-09-2002, 09:42 PM

Posting Permissions

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