Welcome to WebmasterWorld Guest from 54.163.40.152

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Php header and footer in cgi

Add php header and footer to cgi?

     

buzzeman

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

10+ Year Member



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

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

WebmasterWorld Senior Member 10+ Year Member



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

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

10+ Year Member



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

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

WebmasterWorld Senior Member 10+ Year Member



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

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

10+ Year Member



Thanks Andreas.

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

buzzeman

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

10+ Year Member



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

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

WebmasterWorld Senior Member 10+ Year Member



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

 

Featured Threads

Hot Threads This Week

Hot Threads This Month