Posted By

letanure on 01/14/11


Tagged

php highlight syntax printr vardump


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

letanure
ericserrat
jirimelcak


alternative to print_r with syntax highlight


 / Published in: PHP
 

alternative to print_r with syntax highlight using jquery

  1. function test($var, $lang = 'php', $apenas_var = true, $die = true){
  2. if($apenas_var)
  3. echo '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>';
  4. echo '<script type="text/javascript" src="http://github.com/balupton/jquery-syntaxhighlighter/raw/master/scripts/jquery.syntaxhighlighter.min.js"></script>';
  5. echo '<script type="text/javascript">$.SyntaxHighlighter.init();</script>';
  6. echo '';
  7. echo '<code id="printR" class="language-'.$lang.'" style="margin:50px 10%; width:80%;">';
  8. if($lang == 'html')
  9. else
  10. print_r($var);
  11. echo '</code>';
  12. if($die){
  13. die('end');
  14. }
  15. }

Report this snippet  

You need to login to post a comment.