[ create a new paste ] login | about

Link: http://codepad.org/pCBTHEtv    [ raw code | output | fork ]

aceballos - PHP, pasted on Apr 18:
<?php

#
# ================================== [ debug.php (fragment)
#

  function shout($char_class, $obj_this)
    { 
    #
    switch ($char_class)
      {
      case 'f': {
        print "<br><strong style=\"color:#006;\">FUNCTION: </strong> $obj_this \n";
        break; }
      case 'p': {
        print "<br><br><strong style=\"color:#F93;\">SECTION:</strong> $obj_this \n";
        break; } 
      case 'i': {
        print "<br><strong style=\"color:#9CF;\">INFO STATUS:</strong> $obj_this \n";
        break; }
      case 'e': {
        print "<br><strong style=\"color:#600;\">ERROR:</strong> $obj_this \n";
        break; } 
      case 'q': {
        print "<br><strong style=\"color:#33C;\">QUERY:</strong> $obj_this \n";
        break; }
      case 'r': {
        print "<br><strong style=\"color:#669;\">RESULT:</strong> $obj_this \n";
        break; }
      case 's': {
        print "<br><strong style=\"color:#06F;\">SYSTEM:</strong> $obj_this \n";
        break; }
      case '@': { 
        print "<br><strong style=\"color:#C90;\">ARRAY:</strong> ";
        print "<ol><li>".join ("</li>\n<li>",$obj_this)."</li></ol> \n";         
        break; }
      case '%': { 
        print "<br><strong style=\"color:#093;\">HASH:</strong> <ul> \n";
        foreach (array_keys($obj_this) as $str_thiskey) { print "  <li>$str_thiskey: $obj_this[$str_thiskey] </li> \n"; }
        print "</ul> ";
        break; }
      case '?': {
        print "<br><strong style=\"color:#90F;\">STRUCTURE ".gettype($obj_this).":</strong>".print_r($obj_this)." \n";
        break; }
      default: {
        print "<br><strong style=\"color:#999;\">- :</strong> $obj_this \n";
        break; }
      }   
    }
 
#
# Obscure string

  function obscure($str_value)
    { 
    $int_length = strlen($str_value);
    $int_quarter = floor($int_length/4);
    return substr($str_value,0,$int_quarter).str_repeat('-',$int_length-(2*$int_quarter)).substr($str_value,$int_length-$int_quarter); 
    }

#
# ================================== [ example 
#

$bool_DEBUG = 1;

$str_secretword = "MySecretWordNotToShow";
$arr_this = range(10,20);
 

if ($bool_DEBUG) shout('i',"My secret word: ".obscure($str_secretword));

for ($i=0; $i<count($arr_this); $i++) {
  $arr_this[$i] = $i + floor(rand()*100);
  }
if ($bool_DEBUG) shout ('@',$arr_this);
 

?>


Output:
1
2
3
4
5
6
7
8
9
10
11
12
<br><strong style="color:#9CF;">INFO STATUS:</strong> My secret word: MySec-----------oShow 
<br><strong style="color:#C90;">ARRAY:</strong> <ol><li>13993426300</li>
<li>15445270401</li>
<li>99056882002</li>
<li>165929156303</li>
<li>170879951604</li>
<li>137230035605</li>
<li>19110220906</li>
<li>134459598307</li>
<li>103240581508</li>
<li>198355256509</li>
<li>25104119310</li></ol> 


Create a new paste based on this one


Comments: