php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #45612 server version of php should ignore first line starting with #!
Submitted: 2008-07-24 00:51 UTC Modified: 2013-07-30 03:08 UTC
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:3 (100.0%)
From: ganswijk at xs4all dot nl Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 5.2.6 OS: unix
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ganswijk at xs4all dot nl
New email:
PHP Version: OS:

 

 [2008-07-24 00:51 UTC] ganswijk at xs4all dot nl
Description:
------------
Perhaps it's a good idea to let the server version of php ignore the first line of a script when it starts with '#!'.

That way you can write a script that can serve as a batch script and as  a server version of the script which is completely identical and not have the server version show the first line starting with '#!' in the browser screen.

It would also be nice to know which criterium a script should use to determine if it's running as a server script or as a CLI script. Currently I'm considering using $_SERVER or using some test on $argv.



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-09 10:01 UTC] dhaarbrink at gmail dot com
This issue is still current for 5.4.3.

This should definitely be addressed.

As to the reporter: you can use php_sapi_name() and check if it returns 'cli'.
 [2013-07-30 03:08 UTC] yohgaki@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2013-07-30 03:08 UTC] yohgaki@php.net
Server version of PHP is supposed to be a embedded script. (Even if when we don't 
want it) Therefore, PHP should output anything out side of PHP tags.

You may be interested in this RFC.

https://wiki.php.net/rfc/nophptags
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 05:01:33 2025 UTC