Edit report at https://bugs.php.net/bug.php?id=64488&edit=1
ID: 64488 Updated by: m...@php.net Reported by: php at richardneill dot org Summary: Allow open tag to "discard the previous shebang" -Status: Open +Status: Duplicate Type: Feature/Change Request Package: CGI/CLI related PHP Version: 5.4.13 Block user comment: N Private report: N New Comment: See req #31563 Previous Comments: ------------------------------------------------------------------------ [2013-03-22 23:46:17] 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-03-22 10:32:27] php at richardneill dot org Description: ------------ 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: --------------- #!/usr/bin/php <? if (php_sapi_name()== "cgi"){ erase_previous_line() <-- hypothetical function. echo "I am CGI<br>"; }else{ 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: "#!/usr/bin/php 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64488&edit=1