php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8506 CGI PHP doesn't erase the #!/path/to/php
Submitted: 2000-12-31 21:13 UTC Modified: 2002-06-18 18:18 UTC
From: vladnc at hotmail dot com Assigned:
Status: Closed Package: *General Issues
PHP Version: 4.0.4 OS: Red Hat Linux release 6.0
Private report: No CVE-ID: None
 [2000-12-31 21:13 UTC] vladnc at hotmail dot com
The script is:

--- Cut ---
#!/home/vladimir/php4/bin/php
<% phpinfo () %>
--- Cut ---

You can see the result at http://book.ecompare-corp.com/cgi-bin/vxml/engines/kbb/phpinfo.php

The first line of the page is #!/home/vladimir/php4/bin/php, and that's very annoying. I'm using PHP to generate XML output, and the XML parser that will read the output doesn't like the first line, and I can't blame it.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-02 14:49 UTC] jmoore@php.net
PHP does not require the first line that you are including unlike perl due to the way its set up in apache.
 [2001-01-02 15:29 UTC] vladnc at hotmail dot com
   "PHP does not require the first line that you are including unlike perl due to the way its set up in apache."

   You're wrong. PHP is not set up at all in Apache. Look what happens if I delete the first line:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>500 Internal Server Error</TITLE>
</HEAD><BODY>
<H1>Internal Server Error</H1>
The server encountered an internal error or
misconfiguration and was unable to complete
your request.<P>
Please contact the server administrator,
 webmaster@book.ecompare-corp.com and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.<P>
More information about this error may be available
in the server error log.<P>
<HR>
<ADDRESS>Apache/1.3.12 Server at book.ecompare-corp.com Port 80</ADDRESS>
</BODY></HTML>

Server error log:
[Mon Jan  1 16:00:34 2001] [error] [client 212.54.118.28] Premature end of script headers:
 /home/httpd/cgi-bin/vxml/engines/kbb/phpinfo2.php


 [2001-01-02 15:41 UTC] vladnc at hotmail dot com
   And if you still have any doubts, thinking that Apache has reconized the file extension and is not using the cgi version, try 

http://book.ecompare-corp.com/cgi-bin/vxml/engines/kbb/phpinfo.vxml

   The output is the same. And if you read the php output on both pages you'll see that PHP is run as CGI (Server API CGI).

 [2001-03-06 08:01 UTC] stas@php.net
What is your apache configuration for PHP scripts?
 [2001-03-08 09:12 UTC] vladnc at hotmail dot com
    The only lines concerning PHP in httpd.conf are:

AddType application/x-httpd-php3 .php3
AddType application/x-httpd-php3-source .phps

    And, since I use .php as file extension, this lines are irrelevant.

 [2001-03-12 11:41 UTC] vladnc at hotmail dot com
denice.deatrich@epfl.ch has a similar problem on a different platform:
--- Start Quote ---
This problem exists also for NT4 with server signature:
 Server: Apache/1.3.14 (Win32) PHP/4.0.4pl1

If I do not put:
   #!/php/php
at the top of the file then I get an apache server error and this
message in error.log:

[Mon Mar 12 14:08:39 2001] [error] [client xxxx] c:/apache/cgi-bin/hello.php4 is not executable; ensure interpreted scripts have "#!" first line
[Mon Mar 12 14:08:39 2001] [error] [client xxxx] couldn't spawn child process: c:/apache/cgi-bin/hello.php4

As soon as I put it back it works.
An example script:

#!/php/php
<?php
echo "<br>hello cgi<br>";
?>

but the html-source generated by this is (from browser's "view source"):
#!/php/php
<br>hello cgi<br>

Of course, you can hide it with a trick like:
<body bgcolor="black"><font color="white">...
but that's ugly too...
--- End Quote ---
 [2001-04-16 06:57 UTC] jmoore@php.net
dup of 8898
 [2002-06-18 18:18 UTC] sniper@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 01:01:28 2024 UTC