November 17th, 1999, 05:11 PM
Is there a way to have PHP code included into HTML generated by a CGI/PERL script? The problem is that the CGI-generated HTML can not be interpreted/parsed by PHP. Unless you know how.
November 18th, 1999, 10:18 AM
I don't know what you mean by the second sentence. PHP doesn't parse HTML, the browser does that.
All you have to do is output the PHP code with the HTML and make sure that the file has the appropriate extension so that it gets parsed by PHP when it's accessed (probably .phtml or .php3) instead of going directly to the client as with .htm or .html.
I'm not sure why you think this isn't possible. Have you tried it? If you have and it hasn't worked describe in detail what you did and what went wrong.
November 22nd, 1999, 04:45 PM
The problem is that when CGI returns HTML, it still comes with CGI extension (http://www.host.com/cgi-bin/file.cgi).
November 23rd, 1999, 09:44 AM
Just rename the file.
December 1st, 1999, 01:28 PM
It depends in wich way you output the html...
If you want the cgi-script to generate pages on your server, just write the php-code in it, like this: (FILE is a handler to the file you want to create on your server..)
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
$page_id = "2054";
blabla and some more...
on the other hand, if somebody does a get-query on one of your cgi-scripts, it's not possible...
Have Fun !
December 9th, 1999, 08:27 PM
If I understand correctly, you're trying to output PHP code from a Perl script, and have it execute right then? This is not possible.
Then again, now that I think about it, it might actually be possible, but how to do it is beyond me.
Let me explain. In the normal course of events, you write a PHP script and place it in a file with an extension of PHP3 or PHTML, depending on what version you're using. When someone requests this file, the web server sees this extension and, rather than outputting it directly to the visitor, passes it to the PHP parser, which executes any PHP code in the file and *then* outputs it to the visitor.
The same thing essentially happens with your Perl script -- the web server passes it to the Perl parser for processing, rather than outputting it directly to the visitor. Anything output by your Perl script then goes directly to the visitor -- including any PHP code. Since the PHP parser never gets called, there's nothing to parse the PHP code.
If you could have your Perl script call the PHP parser and pipe its output there, you might get somewhere. I don't know if/how you would do that, though.
Or *why* for that matter!
Holotech Web Design
December 10th, 1999, 09:53 AM
Ahhh. I didn't read into it that he wanted immediate execution. After printing to the file as SJONdaMON describes, you can redirect to that file using a header. I still don't understand why you say it isn't possible to set the extension on the file??
December 11th, 1999, 03:04 PM
What about calling the cgi script with vars from within a php3 file?
(initial.php3) <--- user-data entry
(second.php3) <--- include /cgi-bin/script.cgi?VARS
~the brain dump~
December 11th, 1999, 08:39 PM
An easy way 'round is to call the cgi script by http, and not the local server path, like this: