//flex table opened by JP

Click to See Complete Forum and Search --> : PHP shebang


jjinno
09-21-2004, 12:02 PM
I have to put the shebang #!/usr/local/bin/php at the top of every php file that is not already included in a php file with the shebang, in order for my web-server to be able to handle it.

Is there a way that I can, instead of just putting the shebang, say something like:

if the path to php has not already been defined
then define the path as #!/usr/local/bin/php

- Jinno

CompGeek01
09-21-2004, 01:59 PM
I have never personally had this problem...because the path has alwasy been set in my config file for PHP...but I found a possible solution through Google using ini_set:


<?php
$sep = ( strstr( strtoupper( PHP_OS ) , 'WIN' ) ) ? ';' : ':' ;
ini_set( 'include_path' , ini_get('include_path') . $sep . '/path/to/add' );
?>

jjinno
09-21-2004, 03:23 PM
The problem with this is that it is using PHP code. My school's webserver will not even be able to parse this code, because it is within the <?php ?> tags.

Now correct me if I am wrong, but PHP is a language built off from the Perl language, which was originally developed as an extension to the C/C++ language base.

If the reasoning follows that anything done in C/C++ could be done/accessed by PHP, then the shebang would actually fall under the same category as:
#include
in C/C++. Now, I am going on huge assumptions here, but that would mean that the code could use something like:
#ifndef '!usr/local/bin/php'

I dont even know.....
- Jinno

"Google!!! Dont Fail Me Now!!!"

slam
09-21-2004, 03:48 PM
is your school running apache? if so , have them set it to automatically parse php scripts. It should be able to identify the script by the php extension.

CompGeek01
09-21-2004, 03:49 PM
My apologies, but 99% of the PHP programming I have ever done and seen occurs between <? and ?>. Best thing I can tell you is to try it out...

I think you're right in that PHP was built off a PERL CGI written a long while ago (well, like 10 years?)...but has since been rewritten in C blah blah blah.

I might ask you what you are trying to accomplish...you're still going to have to ask the server to parse each file with PHP unless you somehow configure it to parse all files with php...but I think that would be pointless as well.

#!/usr/local/bin/perl

MJCfromCT
09-21-2004, 04:32 PM
i PM'ed jjinno - the site he had put up was interperting extra shebangs as text on the top of the site, by removing all the shebangs from the php files except the main ones, problem solved :)

jjinno
09-21-2004, 11:18 PM
well, MJC, problem almost solved...lol

I was able to fix most of the errors with the removal of the extra shebangs. Unfortunately, the modules within PostNuke still do not all work...(some just spawn a white screen with a shebang at the top)

I am wondering if "re-instancing" the PHP document could possibly be the cause of this....IE: The index.php file needs to load index.php (itself) to do a refresh, but also thus re-runs the shebang line.

As to asking my admins to do something about this globally, I basically was told that I "dont know about what they do, or why they do it" so I should basically leave them to their bussiness, because they "have a reason for having PHP installed as it is".

Anywho, i am so far down the totem poll, that I would be laughed at to suggest that they could do something better than what they are doing. Yea for Tech-Schools, who obviously are the "best" when it comes to using technology...lol.

:D