PHP Classes

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of Shane Kretzmann  >  Firebug Console Log  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Shows how this class is used
Class: Firebug Console Log
Log debug output to show in Firebug console
Author: By
Last change: Forced turning on error reporting and removing the display to screen
Date: 3 years ago
Size: 1,927 bytes


Class file image Download
* Example of how to use class.consoleLog.php by Shane Kretzmann
// turn on reporting of all errors but suppress the screen echo
ini_set('display_errors',0); error_reporting(E_ALL);

// start up the class (self initiating with object name: $console)
// Once loaded all PHP Notices, Warnings, Errors and UnCaught Exceptions will automatically get logged
// to the firebug console.

$showInConsole = array( // build settings array for what we want to show up in console
'log' => true,
'info' => true,
'debug' => true,
'warnings' => true,
'errors' => true,
'exceptions' => true,
$console->settings($showInConsole); // This is optional, the class defaults to everything on

// Various ways to push information to the firebug console
$console->log('This is a Log to Console from PHP');
$console->info('This is a Info push to Console from PHP');
$console->debug('This is a debug push to Console from PHP');
$console->warn('This is a Warning push to console from PHP');
$console->error('This is a Error push to console from PHP');

// This examples shows how you can pass an array thru to the console
// You can also pass variables and objects in this manner.
$array = array('test'=>'value of test','test2'=>'value of test2');
$console->debug('Example of passing an array to console: Inside $array we have:',$array);

'Open your firebug console in order to see the results of this example file<br>';

// here we force a PHP notice
echo Enjoy;

# The next two examples both cause the loading of the page to stop
# To see each on you will need to uncomment the other :P

// here we force a PHP Warning and Fatal Error

// Now to show you how Exceptions are caught with this class and pushed to firebug console
# throw new Exception('Just throwing it out there (exception example)');