procedural.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. *
  4. * This file is part of FirePHP (http://www.firephp.org/).
  5. *
  6. * Software License Agreement (New BSD License)
  7. *
  8. * Copyright (c) 2006-2009, Christoph Dorn
  9. * All rights reserved.
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. *
  14. * * Redistributions of source code must retain the above copyright notice,
  15. * this list of conditions and the following disclaimer.
  16. *
  17. * * Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. *
  21. * * Neither the name of Christoph Dorn nor the names of its
  22. * contributors may be used to endorse or promote products derived from this
  23. * software without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  26. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  27. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  28. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  29. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  30. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  31. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  32. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  34. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. /* NOTE: You must have the FirePHPCore library in your include path */
  38. set_include_path('./../lib/'.PATH_SEPARATOR.get_include_path());
  39. require('FirePHPCore/fb.php');
  40. /* NOTE: You must have Output Buffering enabled via
  41. ob_start() or output_buffering ini directive. */
  42. fb('Hello World'); /* Defaults to FirePHP::LOG */
  43. fb('Log message' ,FirePHP::LOG);
  44. fb('Info message' ,FirePHP::INFO);
  45. fb('Warn message' ,FirePHP::WARN);
  46. fb('Error message',FirePHP::ERROR);
  47. fb('Message with label','Label',FirePHP::LOG);
  48. fb(array('key1'=>'val1',
  49. 'key2'=>array(array('v1','v2'),'v3')),
  50. 'TestArray',FirePHP::LOG);
  51. function test($Arg1) {
  52. throw new Exception('Test Exception');
  53. }
  54. try {
  55. test(array('Hello'=>'World'));
  56. } catch(Exception $e) {
  57. /* Log exception including stack trace & variables */
  58. fb($e);
  59. }
  60. fb('Backtrace to here',FirePHP::TRACE);
  61. fb(array('2 SQL queries took 0.06 seconds',array(
  62. array('SQL Statement','Time','Result'),
  63. array('SELECT * FROM Foo','0.02',array('row1','row2')),
  64. array('SELECT * FROM Bar','0.04',array('row1','row2'))
  65. )),FirePHP::TABLE);
  66. /* Will show only in "Server" tab for the request */
  67. fb(apache_request_headers(),'RequestHeaders',FirePHP::DUMP);
  68. print 'Hello World';