A simple PHP debugging tool to display various PHP variables such as GET, POST, SESSION, COOKIE, and SERVER variables. It also provides error and exception handling, and allows exporting the debug information as an HTML file.
- Display GET, POST, SESSION, COOKIE, and SERVER variables.
- Error and exception handling.
- Export debug information as an HTML file.
- Toggle debug information visibility.
- Filter debug information using a search box.
- Automatically disabled in production environments.
- Clone the repository or download the
debug.php
file. - Create an empty
.env_dev
file in the same directory asdebug.php
to enable debugging.
Create an .env_dev
file in the same directory as debug.php
:
touch .env_dev
- Include
debug.php
in your main PHP script before any output is generated.
Include the debug.php
file at the beginning of your main PHP script:
<?php
include 'path/to/debug.php';
?>
Call the showDebugInfo()
function at the end of your main PHP script to display the debug information. This function will do nothing in production environments:
<?php
// Example variables
$_SESSION['username'] = 'demo_user';
$_GET['page'] = 'home';
$_POST['submit'] = 'Submit';
$_COOKIE['user'] = 'cookie_user';
$_SERVER['REQUEST_TIME'] = time();
// Add a custom debug message
debug_message('This is a custom debug message for demonstration purposes.');
// Display debug information
showDebugInfo();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>PHP Debugging Tool Demo</title>
</head>
<body>
<h1>Welcome to the PHP Debugging Tool Demo</h1>
<p>This is a demo page to showcase the PHP Debugging Tool functionality.</p>
<form method="post" action="">
<input type="text" name="demo_input" placeholder="Enter something...">
<input type="submit" name="submit" value="Submit">
</form>
<p>Some content on the page...</p>
<p>More content...</p>
<?php
// Include the debug script
include 'path/to/debug.php';
// Example variables
$_SESSION['username'] = 'demo_user';
$_GET['page'] = 'home';
$_POST['submit'] = 'Submit';
$_COOKIE['user'] = 'cookie_user';
$_SERVER['REQUEST_TIME'] = time();
// Add a custom debug message
debug_message('This is a custom debug message for demonstration purposes.');
// Display debug information
showDebugInfo();
?>
</body>
</html>
Add a custom debug message to be displayed.
$message
(string): The message to be displayed.
Displays the debug information at the point where it is called. It should be called at the end of your script to ensure all variables are captured. In production environments, this function does nothing.
To export the debug information as an HTML file, append ?export_debug=1
to the URL in your browser.
Example:
http://yourdomain.com/yourscript.php?export_debug=1
This project is licensed under the MIT License - see the LICENSE file for details.