Posted By

cerxx on 10/30/18


Tagged

tools


Versions (?)

PHP analog of console.log () function


 / Published in: PHP
 

URL: http://pavluha.net/php-analog-funktsii-console-log.html

Debugger analog for PHP: debugger console_log ().

  1. function console_log() {
  2. static $f = false;
  3.     if (!func_num_args()) return; # Argumenty` ne peredany`
  4.     if (!$f) $f = fopen('!console.log',"w");
  5.     foreach (func_get_args() as $arg) {
  6.         if (is_bool($arg)) $s = $arg?'TRUE':'FALSE';
  7.         elseif (is_array($arg) or is_object($arg)) $s = print_r($arg, TRUE);
  8.         else $s = $arg;
  9.         fwrite($f,$s.' '); # vy`vod argumentov razdeliaetsia probelom
  10.     }
  11. }
  12.  
  13. //Primer ispol`zovaniia
  14. # skript vy`polniaetsia, peremenny`e sozdaiutsia
  15. $a = array('name'=>'PHP debagger console_log()', 'txt'=>'Primer ispol`zovaniia');
  16. $b = isset($a); # ?.?. TRUE
  17. $c = time();
  18. # a teper` uznaem, kak u nas dela
  19. console_log('$a',$a,'$b',$b,'? ??? $c',$c);

Report this snippet  

You need to login to post a comment.