Re: Make PHP Execute in CGI output
by miyagawa (Chaplain) on Dec 01, 2001 at 18:49 UTC
|
| [reply] |
|
- We are not yet running under mod_perl. Converting all our scripts to be able to do so is way up there on my todo list
- All our PHP installations are of the Apache Server module variety so we have no command line PHP available.
- Is there any documentation for php-perl?
| [reply] |
Re: Make PHP Execute in CGI output
by belg4mit (Prior) on Dec 01, 2001 at 20:05 UTC
|
| [reply] |
Re: Make PHP Execute in CGI output
by DaWolf (Curate) on Dec 01, 2001 at 23:27 UTC
|
Ok, maybe it's not the easier way, but I think it will work:
1) First create a file and put the code into it.
2) Make the browser load the file.
For an example (using your code):
open (THP, ">foo.php"); # THP means TemporaryPHP hehe
print THP>>The_End;
<!-- Initial HTML code-->
<?php include('header.php'); ?>
<body>
<!--rest of doc-->
</body>
</html>
The_End
close (THP);
print "Location: http://URL_to_the_file/foo.php\n\n";
Best regards,
Er Galvão Abbott
a.k.a. Lobo, DaWolf
Webdeveloper
| [reply] [d/l] |
Re: Make PHP Execute in CGI output
by giulienk (Curate) on Dec 02, 2001 at 01:08 UTC
|
Maybe you should check for Apache::SSI or, as you don't use mod_perl, CGI::SSI. I didn't get as far to look at CGI::SSI code but i suppose it gets the file you want to include via LWP and then include it in your page. I think that's not really optimized but will do the work.
gkinueliileunikg | [reply] |
Re: Make PHP Execute in CGI output
by perrin (Chancellor) on Dec 02, 2001 at 00:32 UTC
|
You probably could solve this problem using one of the ways suggested already, but if you care about performance of your app, don't do it. It's always slow to do this kind of interaction between multiple interpreters. You'd be better off teaching them some SSI syntax (there are modules for simulating SSI on CGI output) or in-line perl.
If you switch to mod_perl, you might be able to rig something up that would be no worse than your current CGI in terms of performance, but it's still probably not worth the trouble ultimately. | [reply] |
Re: Make PHP Execute in CGI output
by Anonymous Monk on Dec 02, 2001 at 02:49 UTC
|
If you are not getting any returned values, like a counter or something, you could do any of the following:
print "<script src=\"counter.php\"></script>";
#or this, but it is IE4+ only:
print "<iframe src=\"counter.php\" height=1 width=1></iframe>";
#or you could just create a hidden frame and place your script in thei
+r using frames...
#Why not just implement your site in PHP?
| [reply] [d/l] |
Re: Make PHP Execute in CGI output
by Anonymous Monk on Dec 02, 2001 at 02:43 UTC
|
On a unix box, just change the shebang line:
#!user/lib/pathtophp/php
//PHP code starts here
echo "Wuzzup, world!"; | [reply] |
Re: Make PHP Execute in CGI output
by flocto (Pilgrim) on Dec 03, 2001 at 02:46 UTC
|
I don't really have any great php experience, but as far as i know there is a binary, called "php" which works much the way the perl executable works. You could pipe all your output through this program (after you're done generating the file) and return it's output to apache as if it was from your script. You could do this by writing a small mod_perl script or implementing it directly into your script(s). Again: I don't know very much about this binary, maybe it doesn't take code from STDIN, maybe it doesn't return to STDOUT, I really don't know very much about this program, but it might work.
Good luck :)
octo
--
GED/CC d-- s:- a--- C++(+++) UL+++ P++++$ L++>++++ E--- W+++@ N o? K? w-- O- M-(+) V? !PS !PE !Y PGP+(++) t-- 5 X+ R+(+++) tv+(++) b++@ DI+() D+ G++ e->+++ h!++ r+(++) y+ | [reply] |
Re: Make PHP Execute in CGI output
by Anonymous Monk on Dec 03, 2001 at 04:17 UTC
|
http://freshmeat.net/projects/phpperl/
-deek | [reply] |
Re: Make PHP, yatta yatta....
by bawy (Initiate) on Dec 03, 2001 at 13:29 UTC
|
Hey, I posted the "If you are not getting any returned values" post a while ago, I thought of more options:
You can use the exec() function, it is available in both Perl and PHP so you can crossexecute that way:
exec("c:/php/php.exe counter.php");
<? exec("c:/perl/perl.exe counter.pl"); ?>
You could probably use the LWP module in Perl and pull in the PHP page, although this would be kinda slow considering it is an extra HTTP call for each page. | [reply] [d/l] |
|
my $html =<<HTML;
Content-type: text/html\n\n
<?php include('header.php'); ?>
<body>
<!-- rest of doc -->
</body>
</html>
HTML
open PHP, '>phpinput.php';
print PHP $html;
close PHP;
#-q option to PHP forces it to leave off http headers
my $output =eval {`/usr/local/php/bin/php -q phpinput.php`};
print $output unless $@;
| [reply] [d/l] |