RE: [PHP] #!/usr/bin/php in output?
| From: | Kearns, Terry | Date: | Thu, 07 Mar 2002 07:16:41 +0000 |
| Subject: | RE: [PHP] #!/usr/bin/php in output? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-87586@lists.php.net to get a copy of this message | ||
OK, the only reason you would have #!/usr/bin/php is if you're going to run
it as a shell script under unix.
You approach should _still_ be 2 scripts (3 if you count the include file).
<file_content file="for_shell.php">
#!/usr/bin/php
<?php include('main_code.php'); ?>
</file_content>
<file_content file="for_cgi.php">
<?php include('main_code.php'); ?>
</file_content>
If the script really must be one and the same (name and path), then maybe
<file_content file="called_script.php">
#!/usr/bin/php
<html><head><title>redirect</title>
<?php
if(!isset(HTTP_REFERRER)):
echo '<meta http-equiv="refresh" content="0;URL=cgi_code.php">';
else:
include('cgi_code.php');
endif;
?>
</head><body></body></html>
</file_content>
Maybe the php executable will ignore the stuff not in <? ?> and not output
the HTML
[TK]
> -----Original Message-----
> From: Mike Eheler [mailto:mike@idearesource.com]
> Sent: Wednesday, 6 March 2002 9:26 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] #!/usr/bin/php in output?
>
>
> It needs to run as a CGI script.
>
> The reason is maybe it needs to be a dual-purpose script that
> can be run
> from the console, or from the web, or maybe it needs to run as a user
> other than the web server. Whatever my actual reason is
> doesn't matter,
> but trust me, the script must be run as a CGI.
>
> Mike
>
> Anas Mughal wrote:
> > Why do you have "#!/usr/bin/php" in your script?!
> > You are running it thru the webserver. You shouldn't
> > need that line.
> >
> >
> >
> > --- Mike Eheler <meheler@idearesource.com> wrote:
> >
> >>Having a bit of a weird problem with using PHP as
> >>CGI. The problem is
> >>this.. the output is returning the #!/usr/bin/php
> >>line from the file.
> >>
> >>Example:
> >>
> >>/cgi-bin/test:
> >>
> >>#!/usr/bin/php
> >><?
> >> echo "Hello World!\n";
> >>?>
> >>
> >>Then in a web browser:
> >>http://www.example.com/cgi-bin/test:
> >>
> >>#!/usr/bin/php
> >>Hello World!
> >>
> >>Has anyone else experienced this problem or know
> >>what's causing it?
> >>
> >>Mike
> >>
> >>--
> >>PHP General Mailing List (http://www.php.net/)
> >>To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> >
> > =====
> > Anas Mughal
> > anasmughal@yahoo.com
> > anasmughal@hotmail.com
> > Tel: 973-249-6665
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Try FREE Yahoo! Mail - the world's greatest free email!
> > http://mail.yahoo.com/
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>