Reputation: 722
How can I know in PHP if there is a debugging session? I guess it's when... there is a listening connection. Or when there is a condition to be working (f.e. the cookie XDEBUG_SESSION_START exists)
Upvotes: 0
Views: 411
Reputation: 476
There is a function called xdebug_is_debugger_active() that you can use to check if there is a debugger currently attached.
Reference of all xdebug_ functions here: https://xdebug.org/docs/all_functions
You can also check first if the function exists, in case your code runs where no xdebug us loaded.
if (function_exists("xdebug_is_debugger_active") && xdebug_is_debugger_active()) {
var_dump("I'm being debugged!");
}
Upvotes: 1