|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64488 Allow open tag to "discard the previous shebang"
Submitted: 2013-03-22 10:32 UTC Modified: 2013-09-30 12:13 UTC
From: php at richardneill dot org Assigned:
Status: Duplicate Package: CGI/CLI related
PHP Version: 5.4.13 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: php at richardneill dot org
New email:
PHP Version: OS:


 [2013-03-22 10:32 UTC] php at richardneill dot org
It would be really useful to be able to write single files that would run cleanly 
as *either* CGI or CLI scripts. 

At the moment, the closing '?>' tag will eat the trailing newline.

So, similarly, I'd like to request a way for the opening '<?' tag to eat the 
previous literal shebang line.

Test script:
if (php_sapi_name()== "cgi"){
   erase_previous_line()       <-- hypothetical function.
   echo "I am CGI<br>";
   echo "I am CLI\n";

Expected result:
Exactly one line should be printed: 
  "I am CLI|CGI"

Actual result:
In CLI mode, this script cleanly prints:
  "I am CLI"
but in Apache mode, the script prints the first line literally:
   I am CGI<br>"

It's relatively easy to work around this with a wrapper script, but I'd 
appreciate the elegance of having a single file that can operate in both modes.
Thank you for your time.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-03-22 23:46 UTC] bobwei9 at hotmail dot com
It's principally a good idea, but a function is very complicated to realize as the shebang is already sent when the function will be called.

What I'd prefer is erasing the shebang line every time in a non-cli script when the two first bytes are '#' and '!'. (I'd wonder if there exist some people who really begin the content of their websites with a #!...)
 [2013-09-30 12:13 UTC]
-Status: Open +Status: Duplicate
 [2013-09-30 12:13 UTC]
See req #31563
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 15 05:01:29 2024 UTC