note 93268 added to function.highlight-file

From: Date: Mon, 31 Aug 2009 15:39:20 +0000
Subject: note 93268 added to function.highlight-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-160089@lists.php.net to get a copy of this message
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. ---- Server IP: 194.24.174.37 Probable Submitter: 79.163.130.132 ---- Manual Page -- http://www.php.net/manual/en/function.highlight-file.php Edit -- https://master.php.net/note/edit/93268 Del: integrated -- https://master.php.net/note/delete/93268/integrated Del: useless -- https://master.php.net/note/delete/93268/useless Del: bad code -- https://master.php.net/note/delete/93268/bad+code Del: spam -- https://master.php.net/note/delete/93268/spam Del: non-english -- https://master.php.net/note/delete/93268/non-english Del: in docs -- https://master.php.net/note/delete/93268/in+docs Del: other reasons-- https://master.php.net/note/delete/93268 Reject -- https://master.php.net/note/reject/93268 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#160089) next »