homepage Welcome to WebmasterWorld Guest from 204.236.255.69
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Php header and footer in cgi
Add php header and footer to cgi?
buzzeman




msg:1284120
 9:40 pm on Mar 23, 2003 (gmt 0)

I'm using an ikonboard forum in cgi, and i would like this forum to be in the design of my website. For this i want to include a php header and footer.
Is it possible to include php files in cgi?

 

andreasfriedrich




msg:1284121
 9:57 pm on Mar 23, 2003 (gmt 0)

Welcome to WebmasterWorld [webmasterworld.com] buzzeman.

IŽd suggest reading Marcia`s WebmasterWorld Welcome and Guide to the Basics [webmasterworld.com] post which contains a lot of useful information.

CGI is not a programming language but a convention on how a webserver and external programs may communicate. To answer your question one would need to know which language you are using. For an example of how to include PHP [php.net] scripts into a Perl [perl.com] script see having include problems - Including html file in cgi script [webmasterworld.com].

Andreas

buzzeman




msg:1284122
 10:16 pm on Mar 23, 2003 (gmt 0)

Thanks for your reply.

The ikonboard is in perl. The post you referred to is very helpful. But is there not a more easy way to include a php file in perl, something like include="somefile.php"?

I'm sorry if this is a dumb question :-) It's just that i don't know any perl AT ALL..

andreasfriedrich




msg:1284123
 10:37 pm on Mar 23, 2003 (gmt 0)

There are of course other ways of including the output of a PHP [php.net] call into the output of your Perl [perl.com] script.

Those two lines will run the PHP [php.net] binary. The second method using a list of arguments is safer since it does not use the shell. The output will be sent to STDOUT just like the output of the rest of your Perl [perl.com] script.


$status = system [perldoc.com]("php4 -q /path/top.html");
$status = system [perldoc.com]('php4', '-q', '/path/top.html');

Using backticks you can gather the output of running the PHP [php.net] scripts. This method is inefficient if all you do is print out the variable. So use this only if you want to modify the output from within your Perl [perl.com] script.


$output = `php4 -q /path/top.PHP [php.net]`;

HTH Andreas

buzzeman




msg:1284124
 11:47 am on Mar 24, 2003 (gmt 0)

Thanks Andreas.

I'll give it a try. I hope i get it to work..

buzzeman




msg:1284125
 1:13 pm on Mar 24, 2003 (gmt 0)

Hello,

I used the following code:
#
my $ifile = "php4 -q /home/site1/web/top.html¦";
#
open ('TEMP', $ifile) or die("Can't open file $ifile: $!\n");
my @contents = <TEMP>;
close ('TEMP');
#
print "Content-type: text/html\n\n";
print @contents;

But then I get:
Can't open file php4 -q /your/path/to/top.html¦: No such file or directory

andreasfriedrich




msg:1284126
 1:37 pm on Mar 24, 2003 (gmt 0)

Here are a couple of things to check:

  • Did you replace the broken vertical pipe with the unbroken pipe symbol?
  • Does the php4 binary exist?
  • Is it named php4 or just PHP [php.net]? You would need to adjust the filename accordingly. On *nix system case matters.
  • Is the php4 binary contained in your path? If not use the absolute path instead of just the filename.
  • What OS and server are you running?

Andreas

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved