CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Other Programming Languages: PHP:
php in cgi?

 



ultimategamer2k
User

Jun 20, 2001, 12:41 PM

Post #1 of 21 (54804 views)
php in cgi? Can't Post

is there any way to run a php script in a cgi script?
kind like ssi'ing in a cgi script through an html page...

-------------------------------------------------------------
visit my web site at <a href=http://ultimategamer.cjb.net>here</a>


Jasmine
Administrator

Jun 20, 2001, 1:18 PM

Post #2 of 21 (54798 views)
Re: php in cgi? [In reply to] Can't Post

(Moved thread to php forum from Perl beginners forum)

php is a cgi programming language, so I'm really not sure what you're asking.



alex
stranger

Jun 23, 2001, 3:45 AM

Post #3 of 21 (54791 views)
Re: php in cgi? [In reply to] Can't Post

No, i don't think there is.
Php is dependent on its file extension. You can only execute php script code within a valid php script.. it's different to perl as everything in a perl script is perl, but a php script is really an html doc but with embedded tags representing the php code.
e.g

Code
<HTML><HEAD><TITLE>php page</TITLE> 
</HEAD>
<BODY>
<?
print ("this is php");
?>
<h1>This is html</h1>
</BODY>
</HTML>



ultimategamer2k
User

Jul 6, 2001, 7:51 AM

Post #4 of 21 (54779 views)
Re: php in cgi? [In reply to] Can't Post

i know that, but i want to know if there is any way to execute a php script inside a perl script..... kinda like ssi...
maybe something like
@output = "path/to.php"

?

-------------------------------------------------------------
visit my web site at <a href=http://ultimategamer.cjb.net>here</a>


Kagey
Novice

Jul 22, 2001, 7:30 PM

Post #5 of 21 (54758 views)
Re: php in cgi? [In reply to] Can't Post

In order to do that, the page would have to be sent to 2 different interpreters, which is impossible i think. why use perl at all? stick with php.



Pro_4
User

Jul 22, 2001, 7:54 PM

Post #6 of 21 (54755 views)
Re: php in cgi? [In reply to] Can't Post

Or hey just ditch php all together and do the whole script in perl :p

I am sure whatever you are trying to do with that php stuff it can be done with perl too... unless there is something i missed..

@letters = ('A'..'Z', 'a'..'z', '1'..'5', '_');
@i = ( '15', '43', '40');
print @letters [ @i, -1, 55];


Kagey
Novice

Jul 23, 2001, 9:30 AM

Post #7 of 21 (54750 views)
Re: php in cgi? [In reply to] Can't Post

no way. php is much better



alex
stranger

Jul 23, 2001, 12:41 PM

Post #8 of 21 (54747 views)
Re: php in cgi? [In reply to] Can't Post

PHP was made especially for web server-side scripting.
Perl was adapted to function as a CGI method of parsing requests. Why make it harder on yourself by using such an advanced language as perl when you can have an easier and more successful time with php.



Kagey
Novice

Jul 23, 2001, 7:46 PM

Post #9 of 21 (54744 views)
Re: php in cgi? [In reply to] Can't Post

my point exactly



Pro_4
User

Jul 24, 2001, 11:17 AM

Post #10 of 21 (54739 views)
Re: php in cgi? [In reply to] Can't Post

Because with a more advanced language you get the benefits of more advanced features. Plus i only know Perl so thats my only option. I have looked a little at Php code and so forth but it looked a lot longer to do nearly the same tasks perl does. Maybe i misinterpretted it but i like it when i can write shorter code so it doesnt take as long to pump out scripts.

@letters = ('A'..'Z', 'a'..'z', '1'..'5', '_');
@i = ( '15', '43', '40');
print @letters [ @i, -1, 55];


Jasmine
Administrator

Jul 24, 2001, 11:43 AM

Post #11 of 21 (54736 views)
Re: php in cgi? [In reply to] Can't Post

Both PHP and Perl are well-suited for CGI. Preference usually lies against the unknown. I prefer Perl because I can't program as fluently in PHP as I do Perl. People who know PHP can say the same about PHP.

PHP is a cgi-only language, and if cgi is the reason anyone needs to program at all, then it may be a perfect choice. Perl is a complete programming language that can be programmed for cgi scripts in addition to the development of complete standalone programs (not web-based).

For those who need only cgi programs, then PHP may be their best choice. For those who need to program outside of a cgi-only environment, Perl, C, VB, etc. are more suitable solutions.

The important thing to understand is that saying "x is better than y" merely demonstrates ignorance of the other language and is not factual, regargless of the language discussed. Each language has its strengths and weaknesses. Adcovacy can be a Very Bad Thing when implemented improperly. Check out Mark-Jason Dominus' "Why I Hate Advocacy" article.

The one thing I would ask of Kagey is if "PHP is much better", why do you need to run a Perl script inside your PHP program? That's not a rhetorical question.




alex
stranger

Jul 31, 2001, 11:31 PM

Post #12 of 21 (54724 views)
Re: php in cgi? [In reply to] Can't Post

Oh, i'm not saying PHP is a better language than Perl. I'm just saying it's more suited to web development.. and easier for beginners.
Referring to a previous post stating php code takes a lot longer to do the same tasks perl does - That is completely the opposite. When gathering the information from a form all you need to do is access the input names, they're automatically made available to you unlike perl where you have to parse the STDIN.

I'm not knocking perl.. I love it (why else would I be on this forum?)
And, technically speaking.. PHP isn't CGI. You can compile it on your server as a CGI but it's actually a module.

And..I found out the function to call an external script.
Use Virtual()



widexl
Novice

Aug 18, 2001, 3:02 AM

Post #13 of 21 (54702 views)
Re: php in cgi? [In reply to] Can't Post

My point is do you want what you want or,
do you want what the program language want.

What I like from Perl is that you can do what you want.
What is many times the problem from languages.




Anonymous
Anonymous

Sep 1, 2001, 11:50 PM

Post #14 of 21 (54686 views)
Re: php in cgi? [In reply to] Can't Post

Just to add my 2 cents. PHP actually has two ways to run, as a module and as CGI depending on how it is setup.

The securest way to run it is as a module, but there are host that will compile it to run as a cgi.

As far as wich is better and which is worse, I use both
and find that both have there weaknesses.

Depending on what you are using each for, Perl is more
powerful in some ways and PHP more powerful in others.

Regards,
Ray



Anonymous
Anonymous

Sep 1, 2001, 11:51 PM

Post #15 of 21 (54686 views)
Re: php in cgi? [In reply to] Can't Post

When I say which is better I am speaking of PHP vs Perl.



Anonymous
Anonymous

Feb 25, 2002, 10:57 PM

Post #16 of 21 (54597 views)
Re: [Anonymous] php in cgi? [In reply to] Can't Post

`/usr/bin/php /path/to/filename.php`


ka0osk
Novice

Mar 20, 2002, 2:16 PM

Post #17 of 21 (54585 views)
Re: [Anonymous] php in cgi? [In reply to] Can't Post

CrazyActually, if you are running a small site that will probably not grow too much, PHP will fit the bill, as will Cold Fusion.... BUT... IF you may want to eventually run big iron hi-vol, you will probably have to re-write into modperl or something like it...that is, if you are not into huge server farms in order to handle the load. Bottom line: Its easier to re-write Perl into modPerl, than it is to rewrite from PHP, or install a dozen extra servers. I prefer Perl, even for small sites. It don't crash for no reason as often Cool.

Just my experiance... your mileage may differ. I am doing some sites in PHP also, by the way.. easy to learn.

JSTEP


yapp
User

Apr 3, 2002, 6:34 AM

Post #18 of 21 (54579 views)
Re: [ka0osk] php in cgi? [In reply to] Can't Post

[url=http://www-106.ibm.com/developerworks/web/library/wa-sssl.html]PHP, Perl, Java servlets -- Which one's right for you?

- hope this helps.

Yet Another Perl Programmer

_________________________________
~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool


Cure
User

Nov 29, 2002, 10:28 AM

Post #19 of 21 (54290 views)
Re: [Anonymous] php in cgi? [In reply to] Can't Post

[Anonymous] <->Depending on what you are using each for, Perl is more
powerful in some ways and PHP more powerful in others.



[Anonymous],Please tell me how PHP is more powerful in some ways than Perl.





Cure


localfilmmaker
stranger

Feb 5, 2004, 10:04 AM

Post #20 of 21 (53997 views)
Re: [Anonymous] php in cgi? [In reply to] Can't Post

[code]`/usr/bin/php /path/to/filename.php`[/code]

Thank goodness someone actually addressed the first question! Yes, you can execute a PHP script from a perl script. You call the php interpreter as an external program and tell it which file to parse. Using the backticks you will capture the output from the php interpreter. You can then simply print that out, or do something to it first.


WP
Novice

Feb 7, 2004, 3:18 PM

Post #21 of 21 (53994 views)
Re: [localfilmmaker] php in cgi? [In reply to] Can't Post

...and if you use php as a DSO? :)



Regards,
Paul Wilson
Wilson Programming
http://wilsonprograms.com/

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives