Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 18th, 2005, 11:57 AM   #1
commodore
Programmer
 
Join Date: Nov 2005
Location: Estonia
Posts: 94
Rep Power: 0 commodore is an unknown quantity at this point
CGI vs. PHP

Why do so much people use PHP? I've got the impression that CGI is a lot better than PHP. Maybe I'm wrong?
commodore is offline   Reply With Quote
Old Dec 18th, 2005, 11:59 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
CGI isn't a language, it's an interface. You can't compare dogs and doughnuts (well, maybe you can, if you eat dogs). Your statement is absolutely meaningless.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Dec 18th, 2005, 12:22 PM   #3
commodore
Programmer
 
Join Date: Nov 2005
Location: Estonia
Posts: 94
Rep Power: 0 commodore is an unknown quantity at this point
I'm not stupid. CGI (common gateway interface) is a way of programming web sites. It works like this: someone visits /index.cgi and an app is executed on the server which output is displayed in an html file.

I wanted to know why should I use PHP to make websites not some scripting language or anything. I have seen a cms made in python for example. Why do people make sites in PHP not in some "regular" programming languages?
commodore is offline   Reply With Quote
Old Dec 18th, 2005, 1:18 PM   #4
Darkhack
Hobbyist Programmer
 
Darkhack's Avatar
 
Join Date: Dec 2005
Location: Kansas City
Posts: 102
Rep Power: 3 Darkhack is on a distinguished road
Send a message via AIM to Darkhack
Quote:
Originally Posted by commodore
I'm not stupid. CGI (common gateway interface) is a way of programming web sites. It works like this: someone visits /index.cgi and an app is executed on the server which output is displayed in an html file.

I wanted to know why should I use PHP to make websites not some scripting language or anything. I have seen a cms made in python for example. Why do people make sites in PHP not in some "regular" programming languages?
No one said you were stupid, but your ideas about CGI are inaccurate. You are correct about what CGI is, but I don't think you understand how php fits into the picture. PHP IS a CGI langauge. CGI is just a type of programming language. Other categories include compiled or interpreted, and object oriented or procedural . Also php is a regular scripting language and can do most things that python can do in terms of website scripting.

You got the right idea. Just know that php isn't any different than python or other CGI languages.
Darkhack is offline   Reply With Quote
Old Dec 18th, 2005, 1:32 PM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
CGI is NOT a type of programming language. CGI is a specification for an interface technology. Any number of languages, including PHP, may institute communications in conformance with that interface.

PHP IS a "regular" scripting language. There are many more. Even compiled languages may be used.

I did not say you were stupid, but you seem set on convincing me.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Dec 18th, 2005, 2:42 PM   #6
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
PHP can be used with CGI or as an Apache module (mod_php). The latter is faster because a seperate process doesn't have to be started with each page request...

Microsoft's IIS uses ISAPI, in many ways similar to Apache's modules.

ISAPI, Apache modules, and CGI are merely ways to facilitate extension of the server. PHP, Perl, Ruby, and others are available in different flavors to match whatever the server happens to support. mod_php, mod_perl, mod_ruby on the Apache side, I recall that some of the above support ISAPI, and invariably CGI as an unpleasant fallback.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Dec 18th, 2005, 6:38 PM   #7
Lich
Professional Programmer
 
Lich's Avatar
 
Join Date: May 2005
Location: Detroit
Posts: 254
Rep Power: 4 Lich is on a distinguished road
Send a message via AIM to Lich Send a message via MSN to Lich
commodore,

since the early days of the web, the biggest scripting langauge for server side stuff was PERL. It's powerfull, and people knew how to use it. So when they created ways to make a CGI for web development, PERL was their choice. bit because PERL needed different permissions and configurations (since PERL is, after all, a unix scripting language) in order to run from a web browser, it needed it's own folder. This folder was called the CGI-BIN.

Over time, different ways of applying CGI were used in web sites. ASP ran through Microsoft's IIS Web Server software and didn't require it's own folder. Java Server Pages ran on apache via Tomcat. PHP was written as a module for apache, hence they didn't need their own folders. If someone had, for example, installed the CGI version of PHP rather than the apache module, you would need a CGI-BIN like folder to stick your PHP into. (Just elaborating on what Dameon said). Ruby I believe is stuck right into apache as well.

Over time, things changed. I've used servers were you do not need to have perl scripts in your CGI bin to have them work just fine. But usually you do, so CGI for web was associated with PERL. You're thinking of PERL with this thread, not "CGI".

To answer your initial question, why do people use PHP as oppose to PERL: It's easier to write, develop, debug, you don't need any different settings on it, it's easily portible (so that it will work on PHP on windows, linux, bsd, whatever without complications), and it plays very nicely with databses and has a lot of nice built in functions. PERL is more heavy duty, no doubt about it and the old school web developers still prefer it. But a lot of people feel that PHP will replace Java and PERL as the biggest server side web language.

My advice to you is to judge for yourself. Do some perl tutorials, do some php tutorials. See which language you like best and which is easier to work with.
__________________
--John Cruz
Web Developer
www.cruzweb.net
Lich is offline   Reply With Quote
Old Dec 19th, 2005, 7:11 AM   #8
commodore
Programmer
 
Join Date: Nov 2005
Location: Estonia
Posts: 94
Rep Power: 0 commodore is an unknown quantity at this point
Everyone understood me wrong. I haven't thinked that CGI is a language or anything. The name of the thread was just wrong. And I didn't know that PHP is used with CGI (sorry again if I wrote the sentence wrong).
commodore is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:04 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC