ID: 33392 Updated by: [EMAIL PROTECTED] Reported By: php dot 5 dot magnum3065 at spamgourmet dot com -Status: Open +Status: Bogus Bug Type: CGI related Operating System: Debian GNU/Linux PHP Version: 5.0.4 New Comment:
You're just trying to use the wrong tools (or right tool wrong way). Use the PHP CLI binary instead. There is no bug in the CGI binary.. Previous Comments: ------------------------------------------------------------------------ [2005-06-18 21:50:24] php dot 5 dot magnum3065 at spamgourmet dot com This is for the Trac issue tracking tool: http://projects.edgewall.com/trac We can't use a PHP script to do the highlighting since the application itself is not written in PHP. However some of our users would like to use PHP's syntax highlighting for their source files. So, we're trying to use the PHP executable to perform the highlighting. Unfortunately the _implict_ filename specified by the SCRIPT_FILENAME environment variable is given prescedence over the _explicit_ filename passed as an argument to the executable. This order of prescedence is difficult to work around since it requires unsetting a half dozen environment variables before running the PHP executable. It would be more intuitive to use the SCRIPT_FILENAME only when a filename is not explicitly specified (including calling PHP like "php -- -" to specify reading the input from stdin). ------------------------------------------------------------------------ [2005-06-18 15:08:19] [EMAIL PROTECTED] Write a script and pass the filename as parameter. See: http://www.php.net/manual/en/function.highlight-file.php ------------------------------------------------------------------------ [2005-06-18 06:59:44] php dot 5 dot magnum3065 at spamgourmet dot com Upon further investigation it appears that the SCRIPT_FILENAME variable is actually required if any of the following are set: SERVER_NAME, SERVER_SOFTWARE, REQUEST_METHOD, PATH_TRANSLATED, GATEWAY_INTERFACE. ------------------------------------------------------------------------ [2005-06-18 06:12:43] php dot 5 dot magnum3065 at spamgourmet dot com Oops, the trailing slash on not_me.txt/ is a typo. ------------------------------------------------------------------------ [2005-06-18 06:11:02] php dot 5 dot magnum3065 at spamgourmet dot com Description: ------------ When the SCRIPT_FILENAME environment variable is set this is given precedence over all other ways of providing the input source. I am trying to use the PHP executable to provide syntax highlighting of PHP source within a web application (not PHP-based). However since the PHP executable is called from within the CGI application, the SCRIPT_FILENAME variable is set to the CGI file. So, rather than highlighting the content I've tried passing through stdin, as well as a filename parameter to the executable, PHP processes the CGI file. This filename provided as a command line parameter should be given precedence, and if "-" is given as the filename, the content should be processed from stdin. Reproduce code: --------------- >From a bash command line: $ echo "Content I want highlighted" > process_me.txt $ echo "This gets output instead" > not_me.txt $ export SCRIPT_FILENAME=not_me.txt/ $ php -qs process_me.txt Expected result: ---------------- <code><span style="color: #000000"> Content I want highlighted<br /></span> Actual result: -------------- <code><span style="color: #000000"> This gets output instead<br /></span> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33392&edit=1