Skip to content

Adds web browser console.log for your PHP error messages and user debug messages. e.g. php errors in browser console and some backtrace info for your debug messages (file, class, function, line)

Notifications You must be signed in to change notification settings

78edu/PHP_errors_to_browser_console

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

PHP_errors_to_browser_console

Adds console.log for your PHP error messages and user debug messages.
No conflicts with XDebug - you can use both (even when this script looks incomplete and primitive). But it can show wrong data about dvar_dump( PDO object), seems var_dump works different with var_export in this case. Maybe there is some difference in zend vars.
No more mess in your HTML output when you have errors or want to watch some variables. screenshot


This is used only for development, disable it on deploy.

dprint($string) - works like print, but in your browser console.
dvar_dump($var) - works like var_dump, but in your browser console.

Please note: dprint and dvar_dump output isn't sent to error_log!
This functions is only for display in browser with your exact request.

This script is registering an error handler, it will capture all php errors after script include.

How to use: 1.define("DEBUG",true);
2.require_once(this script) in begining of your index.php
3.Insert in your HTML output <script>$debug_output</script> before
4.Use dprint and dvar_dump to send messages to console.
5.If DEBUG constant is not defined, there will be no debug messages.
6.In production replace dprint and dvar_dump with no operation functions and use display_errors(false) to ensure that you will not get any errors on client side.

About

Adds web browser console.log for your PHP error messages and user debug messages. e.g. php errors in browser console and some backtrace info for your debug messages (file, class, function, line)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages