The Ashes

Technology, Science and other news
September 10, 2009

Formaldehyde: PHP debug info for the client side

Posted by : admin
Filed under : General

Andrea Giammarchi has released Formaldehyde, a new Ajax and PHP error debugger.

Simply grab the project and throw in an inclusion:

PLAIN TEXT
PHP:

  1.  
  2. <?php require_once ‘formaldehyde.php’; ?>
  3.  

You are off to the races.

Want to do a touch more?

PLAIN TEXT
JAVASCRIPT:

  1.  
  2. // *optional* custom ServerError constructor
  3. function ServerError(e){
  4.     for(var key in e)
  5.         this[key] = e[key]
  6.     ;
  7. };
  8. // make Firebug the best friend ever
  9. (ServerError.prototype = new Error).name = “ServerError”;
  10.  
  11. // same call
  12. var xhr = new XMLHttpRequest;
  13. xhr.open(“get”, “test.php”, true);
  14. xhr.onreadystatechange = function(){
  15.     if(xhr.readyState === 4){
  16.         if(199 <xhr.status && xhr.status <400){
  17.             // do something without failures
  18.             eval(xhr.responseText);
  19.         }
  20.        
  21.         // if Formaldehyde managed the call
  22.         else if(xhr.status === 500 && xhr.getResponseHeader(“X-Formaldehyde”) != null) {
  23.        
  24.             // evaluate safely the response
  25.             // generating a proper error
  26.             console.log(new ServerError(eval(“(“ + xhr.responseText + “)”)));
  27.  
  28.         } else {
  29.             // 404 or other cases
  30.             console.log(new Error(xhr.responseText));
  31.         }
  32.     }
  33. };
  34. xhr.send(null);
  35.  

We have known about the great FirePHP for quite some time, but this is different as explained. Check it out!

Tags :

No Comments

(required)
(will not be published) (required)
(opitional)

cciash.com EN ES IT DE PT CZ FR RU
May 2017
M T W T F S S
« Sep    
1234567
891011121314
15161718192021
22232425262728
293031  

Pages

Categories

Resources

There are many online poker site where you can play but at poker.hk you can play the poker games with all the knowledge you need related to the game with the poker school available in both the English and Chinese language.

Super Casino

Now you can bet on any sports and any sporting events from all the comfort from your home. Bet770 allows you to bet on any events and match with in just 3 clicks. They also offers great odds on football betting for every premier and champions league match. Get £50 free in bets when you register.

Bingo770, offering best online bingo games with £7.70 free no deposit Bonus!