Show/Hide Toolbars

Navigation: Advanced topics > Events > Global events

PHPrunner32x32     PHPRunner manual

Event: AfterAppInit

Scroll Prev Next More



Function AfterAppInit is executed in the beginning of each page before any processing takes place. Use this event to override any global PHPRunner variables. See help area in Event editor for the list of available global variables.

yellowbulbNote: It's not recommended to display anything on the web page from this event. This may break your application.



Applies to pages

All pages.


Lets say you need to troubleshoot your application displaying executed SQL query on the top of the page. Usually you proceed to include/appsettings.php file and set $dDebug variable to true though changing this variable back and forth is a little or no joy.

Using AfterAppInit event you can display debug info simply adding debug=true to the URL.

AfterAppInit code:

if ($_REQUEST["debug"]=="true")


Sample URL: categories_list.php?debug=true


Database connection is not yet open in this event. If you need to perform any database operations open database connection manually.



$rs=db_query("select * from users where session_id='" . $_SESSION["sessionid"]. "'",$myconn);




  $_SESSION["Avatar"] = $data["avatar"];


Recommended sample events

Restrict access to PHPRunner application by IP address