[{"ID":"136080D0-EC73-4AFB-99B3-E9A8C9E620A6","title":"aff - python","tags":"python  debug","date":"13\/03\/2018","timestamp":"1520944033","rss_date":"Tue, 13 Mar 2018 13:27:13 +0100","status":"public","dependency":"","source":"http:\/\/warriordudimanche.net","content":"# aff(var)\r\ndef aff(var):\r\n\timport pprint\r\n\tpprint.pprint(var)"},{"ID":"F8F9D784-5FE3-424C-8E24-E3F7FA8CBF4C","title":"aff v2.0","tags":"debug fonctions php","date":"27\/02\/2016","timestamp":"1456580374","rss_date":"Sat, 27 Feb 2016 14:39:34 +0100","status":"public","dependency":"","source":"","content":"\tfunction aff($var,$stop=true){\r\n\t\t$dat=debug_backtrace();$origin='<table>';\r\n\t\techo '<div style=\"background-color:rgba(0,0,0,0.8);color:red;padding:5px\">Arret ligne <em><strong style=\"color:white;font-weight:bold\">'.$dat[0]['line'].'<\/strong><\/em> dans le fichier <em style=\"color:white;font-weight:bold\">'.$dat[0]['file'].'<\/em><\/div>';\r\n\t\techo '<pre style=\"background-color:rgba(0,0,0,0.8);color:#fff;padding:10px\"><code>';var_dump($var);echo '<\/code><\/pre>';\r\n\t\tforeach (array_reverse($dat) as $data){\r\n\t\t\t$dir=dirname($data['file']).'\/';\r\n\t\t\t$fil=basename($data['file']);\r\n\t\t\t$origin.='<tr><td style=\"width:50%\"><em style=\"color:#888\">'.$dir.'<\/em><\/td><td style=\"max-width:10%\"><em style=\"color:white;font-weight:bold\">'.$fil.'<\/em><\/td><td style=\"max-width:10%\"><em style=\"color:yellow;font-weight:bold\">'.$data['function'].'()<\/em><\/td><td style=\"max-width:10%\"> <em style=\"color:lightblue;font-weight:bold\">'.$data['line'].'<\/em> <\/td><\/tr>';\r\n\t\t}\r\n\t\t$origin.='<\/table>';\r\n\t\techo '<div style=\"background-color:rgba(0,0,0,0.8);color:#aaa;padding:10px\">'.$origin.'<\/div>';\r\n\t\tif ($stop){exit();}\r\n\t}"},{"ID":"B127B931-0A5B-4078-9410-EEF05126E77B","title":"Forcer l'affichage des erreurs","tags":"astuce debug php","date":"22\/03\/2015","timestamp":"1427030237","rss_date":"Sun, 22 Mar 2015 14:17:17 +0100","status":"public","dependency":"","source":"http:\/\/blog.medev.ch\/content\/afficher-les-erreurs-php","content":"<?php\r\n  error_reporting(E_ERROR | E_WARNING | E_PARSE);\r\n  ini_set('display_errors', true);\r\n  ini_set('display_startup_errors', TRUE);\r\n?>"},{"ID":"7C9ED99C-6882-4462-B628-9D0141EAE452","title":"afficher variables, fonctions et constantes d\u00e9clar\u00e9es","tags":"astuce debug php","date":"04\/01\/2014","timestamp":"1388854918","rss_date":"Sat, 04 Jan 2014 18:01:58 +0100","status":"public","dependency":"","source":"http:\/\/php.net\/manual\/fr\/function.get-defined-vars.php","content":"\/\/afficher toutes les variables d\u00e9clar\u00e9es\r\nexit('<pre>' . htmlspecialchars(print_r(get_defined_vars(), true)) . '<\/pre>');\r\n\/\/afficher toutes les constantes d\u00e9clar\u00e9es\r\nexit('<pre>' . htmlspecialchars(print_r(get_defined_constants(), true)) . '<\/pre>');\r\n\/\/afficher toutes les fonctions d\u00e9clar\u00e9es\r\nexit('<pre>' . htmlspecialchars(print_r(get_defined_functions(), true)) . '<\/pre>');"},{"ID":"507A1BC7-8853-491A-B69C-007FD2786B77","title":"bloquer la diffusion des erreurs et r\u00e9agir (m\u00eame les fatales)","tags":"php astuce debug","date":"08\/06\/2013","timestamp":"1370711017","rss_date":"Sat, 08 Jun 2013 19:03:37 +0200","status":"public","dependency":"","source":"http:\/\/stackoverflow.com\/questions\/6861033\/how-to-catch-the-fatal-error-maximum-execution-time-of-30-seconds-exceeded-in-p","content":"ini_set('display_errors', '0');         \r\nregister_shutdown_function('shutdown');\r\nfunction shutdown() \r\n{ \r\n       $error = error_get_last();\r\n       if ($error['type'] === E_ERROR) {\r\n\r\n      \/\/do your shutdown stuff here\r\n      \/\/be care full do not call any other function from within shutdown function\r\n      \/\/as php may not wait until that function finishes\r\n      \/\/its a strange behavior. During testing I realized that if function is called \r\n      \/\/from here that function may or may not finish and code below that function\r\n      \/\/call may or may not get executed. every time I had a different result. \r\n\r\n      \/\/ e.g.\r\n\r\n      other_function();\r\n\r\n      \/\/code below this function may not get executed\r\n\r\n       } \r\n\r\n} "},{"ID":"7A7D1DB5-BE1A-4910-9EB0-CCEAA3304952","title":"Fonction d'arr\u00eat et de d\u00e9buggage: AFF()","tags":"php fonctions debug","date":"21\/05\/2013","timestamp":"1369123739","rss_date":"Tue, 21 May 2013 10:08:59 +0200","status":"public","dependency":"","source":"","content":"function aff($a,$stop=true){echo 'Arret a la ligne '.__LINE__.' du fichier '.__FILE__.'<pre>';var_dump($a);echo '<\/pre>';if ($stop){exit();}}\r\n"},{"ID":"1B1CC98F-D101-4E55-8511-6E44BC057D94","title":"n_print: tracer les variables sans exit();","tags":"php fonctions debug","date":"24\/04\/2013","timestamp":"1366834660","rss_date":"Wed, 24 Apr 2013 22:17:40 +0200","status":"public","dependency":"","source":"http:\/\/shaarlet.knah-tsaeb.org\/?HsF04A","content":"<?php\r\n\/**\r\n* Am\u00e9liore la sortie print\r\n*\r\n* @author Tatane http:\/\/www.tatane.info\/index.php\/print_rn\r\n* @author http:\/\/www.blog.cactuscrew.com\/77-print_rn.html\r\n* @param $data (array) tableau ou variable \u00e0 examiner\r\n* @param $name (string) nom a afficher\r\n* @return false affiche les clef valeur du tableau $data\r\n* @example n_print($array, 'Tableau de valeur');\r\n*\/\r\nfunction n_print($data, $name = '') {\r\n$aBackTrace = debug_backtrace();\r\necho '<h2>', $name, '<\/h2>';\r\necho '<fieldset style=\"border: 1px solid orange; padding: 5px;color: #333; background-color: #fff;\">';\r\necho '<legend style=\"border:1px solid orange;padding: 1px;background-color:#eee;color:orange;\">', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '<\/legend>';\r\necho '<pre>', htmlentities(print_r($data, 1)), '<\/pre>';\r\necho '<\/fieldset><br \/>';\r\n}\r\n?>"},{"ID":"015A4E79-8509-47E2-B4EA-BC96E175238D","title":"auto_error_handler","tags":"php fonctions securite debug auto_","date":"23\/04\/2013","timestamp":"1366748260","rss_date":"Tue, 23 Apr 2013 22:17:40 +0200","status":"public","dependency":"","source":"http:\/\/warriordudimanche.net","content":"<?php\r\n# Error handler by bronco@warriordudimanche.net #################\r\nfunction showline($line,$file){\r\n\t$f=file($file);$r='';\r\n\tfor ($l=$line-2;$l<$line+2;$l++){\r\n\t\tif (isset($f[$l])){\r\n\t\t\tif ($l==$line-1){\r\n\t\t\t\t$r.='<em style=\"color:white;text-shadow:0 0 2px black\"><strong>'.$l.' >> <\/strong> '.$f[$l].'<\/em>';\r\n\t\t\t}else{\r\n\t\t\t\t$r.='<strong>'.$l.' >> <\/strong> '.$f[$l];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn $r;\r\n}\r\nfunction error_handler($number, $message, $file, $line, $vars){\r\n\techo \"\r\n\t\t<div style='word-wrap: break-word;Box-sizing: Border-box ;border-radius:5px;padding:15px;margin-bottom:20px;box-shadow:0 2px 1px maroon;font-family:courier;position:absolute;top:0;left:0;background-color:rgba(255,100,100,0.2);width:100%;height:auto;position:relative;min-width:320px;'>\r\n\t\t\t<h1 style='color:red;border-radius:5px;background-color:pink;padding:5px;box-shadow:0 2px 1px maroon'>Erreur $number<\/h1>\r\n\t\t\t<p style=''> <em>$message <\/em> a la ligne <strong style='font-size:24px'>$line<\/strong> dans le fichier <strong style='font-size:24px'>file: $file.<\/strong><\/p>\r\n\t\t\t\r\n\t\t\t<pre style='font-weight:bold;padding:20px;margin-left:10px;color:orange;text-shadow:0 1px 1px maroon;box-shadow:inset 0 2px 1px maroon;border-radius:5px;background-color:red;'><code>\".showline($line,$file).\"<\/pre><\/code>\r\n\t\t\t<h1 style='color:red;border-radius:5px;background-color:pink;padding:5px;box-shadow:0 2px 1px maroon'>Variables<\/h1>\r\n\t\t\t<pre style='overflow:scroll;height:200px;'>\";\r\n\t\t\tvar_dump($vars) ;\r\n\t\t\techo \"<\/pre>\r\n\t\t\t<a style='display:block;text-align:right;font-size:14px;color:maroon;text-decoration:none;font-weight:bold;font-styl:italic;' href='http:\/\/warriordudimanche.net\/'>Error handler par warriordudimanche.net<\/a>\r\n\t\t<\/div>\";\r\n\r\n\tif ( ($number !== E_NOTICE) && ($number < 2048) ) {die(\"Erreur fatale.\");}\r\n}\r\n\r\nset_error_handler('error_handler');\r\n#################################################################\r\n?>"},{"ID":"AA6AD021-AAA6-4C64-BCBC-47D723641716","title":"R\u00e9cup\u00e9rer le code source d'une page en num\u00e9rotant les lignes","tags":"php texte debug","date":"16\/04\/2013","timestamp":"1366143460","rss_date":"Tue, 16 Apr 2013 22:17:40 +0200","status":"public","dependency":"","source":"http:\/\/perishablepress.com\/code-snippets\/#code-snippets_php","content":"\/\/ display source code\r\n$lines = file('http:\/\/google.com\/');\r\nforeach ($lines as $line_num => $line) { \r\n\t\/\/ loop thru each line and prepend line numbers\r\n\techo \"Line #<b>{$line_num}<\/b> : \" . htmlspecialchars($line) . \"<br>n\";\r\n}"},{"ID":"0B9A1917-EDB0-483B-B1C3-1ECEF0782202","title":"Email les erreurs au lieu de les afficher (handler)","tags":"php fonctions debug","date":"16\/04\/2013","timestamp":"1366143460","rss_date":"Tue, 16 Apr 2013 22:17:40 +0200","status":"public","dependency":"","source":"","content":"\r\n\/\/ Our custom error handler\r\nfunction nettuts_error_handler($number, $message, $file, $line, $vars){\r\n\t$email = \"\r\n\t\t<p>An error ($number) occurred on line\r\n\t\t<strong>$line<\/strong> and in the <strong>file: $file.<\/strong>\r\n\t\t<p> $message <\/p>\";\r\n\r\n\t$email .= \"<pre>\" . print_r($vars, 1) . \"<\/pre>\";\r\n\r\n\t$headers = 'Content-type: text\/html; charset=iso-8859-1' . \"rn\";\r\n\r\n\t\/\/ Email the error to someone...\r\n\terror_log($email, 1, 'you@youremail.com', $headers);\r\n\r\n\t\/\/ Make sure that you decide how to respond to errors (on the user's side)\r\n\t\/\/ Either echo an error message, or kill the entire project. Up to you...\r\n\t\/\/ The code below ensures that we only \"die\" if the error was more than\r\n\t\/\/ just a NOTICE.\r\n\tif ( ($number !== E_NOTICE) && ($number < 2048) ) {\r\n\t\tdie(\"There was an error. Please try again later.\");\r\n\t}\r\n}\r\n\r\n\/\/ We should use our custom function to handle errors.\r\nset_error_handler('nettuts_error_handler');\r\n\r\n\/\/ Trigger an error... (var doesn't exist)\r\necho $somevarthatdoesnotexist;"}]