note 93268 deleted from function.highlight-file by googleguy

From: Date: Tue, 22 Oct 2013 11:16:30 +0000
Subject: note 93268 deleted from function.highlight-file by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197060@lists.php.net to get a copy of this message
Note Submitter: Miki Roro ---- highlight_file() wraps HTML tags around PHP constructions, so it's not useful for CLI. If you want to have highlighted source in command line, use this script: <?php $php = $argv[1]; // set a path if(!$php) $php = $argv[0]; $c_string = ini_get('highligth.string'); // get ini values $c_comment = ini_get('highlight.comment'); $c_keyword = ini_get('highlight.keyword'); $c_default = ini_get('highlight.default'); $c_html = ini_get('highlight.html'); $source = highlight_file($php, true); // load highlighted source $source = str_replace('</span>', '', $source); // replace html tags $source = str_replace('<span style="color: #DD0000">', '', $source); $source = str_replace('<span style="color: '.$c_comment.'">', '', $source); $source = str_replace('<span style="color: '.$c_keyword.'">', '', $source); $source = str_replace('<span style="color: '.$c_default.'">', '', $source); $source = str_replace('<span style="color: '.$c_html.'">', '', $source); $source = str_replace('<code>', '', $source); // strip <code> and <br> $source = str_replace('</code>', '', $source); $source = str_replace('<br />', "\n", $source); $source = str_replace('&nbsp;', ' ', $source); // remove &nbsp and entities $source = html_entity_decode($source); echo $source; ?> Then type php highlight.php some_other_script.php to have colorful source in terminal window. Tested under Ubuntu.

« previous php.notes (#197060) next »