.PHP vs. .CGI - pro coders question

Status
Not open for further replies.

allco

New member
Nov 5, 2008
628
8
0
To the pro coders / webhosts.

I'm trying to decide between 2 scripts for a website. One is in .cgi, the other in .php -- both have equally great features. The site will be heavy on reading and writing to mySQL with the script.

Looks like .php has been all the rave in new programs.

In your opinion and study: What is the major difference in why php is more now popular than cgi and is one better than the other performance wise, handling lots of simultaneous users etc. on the deidicated server?

I understand it all depends on how well the original code was written in either language, but what's the big benifit of one over the other etc. ?

Thanks in advance
 


Looks like .php has been all the rave in new programs.

It's been this was since the late 90's. The biggest reason you should go with PHP over Perl now is that you'll have an easier time finding a PHP programmer than a Perl programmer if you need things modified or debugged.
 
cgi is not necessarily perl though. You can use executables with cgi. Cgi is basically just a bigger pain in the ass and nobody really uses it anymore. The biggest advantage you'll have with PHP is that it's actually still used unlike cgi.
 
cgi is not necessarily perl though. You can use executables with cgi. Cgi is basically just a bigger pain in the ass and nobody really uses it anymore. The biggest advantage you'll have with PHP is that it's actually still used unlike cgi.


What he said. Also CGI can be compiled, or can be scripted.

Also I wouldn't say cgi is unused, a lot of payment gateways still use it, as well as specialty software.
 
Hey thanks for the feedback guys.

Out of the 2. Does one use more resources from the server (to operate it's functions overall)? Is one more safe from being hacked etc. over the other?

thanks again
 
Hey thanks for the feedback guys.

Out of the 2. Does one use more resources from the server (to operate it's functions overall)? Is one more safe from being hacked etc. over the other?

thanks again

Depends on the code being executed in terms of resource heavy. As a CGI binary/script can eat the hell out of memory or processor just as bad as a badly written php script.

Far as "being hacked" , both can be hacked if you allow for some kind of exploit or leave something open. (kinda like how if either let you upload a php/cgi to the server to be executed.)

You'll find in general, CGI is restricted more often by hosting providers, and can only be run from certain areas, as you couldn't just call a .cgi from any folder (most are setup where the cgi must be called from the cgi-bin/ folder. ) Also if you're not really a coder or just starting out, you'll find it a lot easier to get started with PHP.
 
mysql is server dependent not script language dependent. So as far as that goes there is no difference performance wise. I don't think you meant to say cgi in particular even though the extension is cgi. It's probably perl. Perl is the front web end of cgi. Just like php is. Cgi is the OS operative. The language is the same but typically anything thats server side or interacts with the OS is cgi for instance deleting a file is CGI and printing to the browser is perl. That is the difference, cgi/perl can interact directly with the server so its best at doing operations that involve that, which is why its so great for scraping and socket controls. php just like perl is just a web scripting language and is only good for creating webpages. It can go much higher than that but most that get to that level end up trying to switch to cgi or python eventually.

What everyone said above is right. Php is easier to learn and a lot more available when finding programmers and cms' to use. Cgi on the other hand is more powerful and flexible when you get to the advanced stuff, not saying you can't do advanced stuff in php but its a lot more difficult and time consuming and there are large limitations such as multithreading, binary manips, and the benefits/availability of CPAN modules. If you're going to pick the language based on the script I say go with the language that is most comfortable for you and your editing abilities, that would most likely be php.
 
mysql is server dependent not script language dependent. So as far as that goes there is no difference performance wise. I don't think you meant to say cgi in particular even though the extension is cgi. It's probably perl. Perl is the front web end of cgi. Just like php is. Cgi is the OS operative. The language is the same but typically anything thats server side or interacts with the OS is cgi for instance deleting a file is CGI and printing to the browser is perl. That is the difference, cgi/perl can interact directly with the server so its best at doing operations that involve that, which is why its so great for scraping and socket controls. php just like perl is just a web scripting language and is only good for creating webpages. It can go much higher than that but most that get to that level end up trying to switch to cgi or python eventually.

What everyone said above is right. Php is easier to learn and a lot more available when finding programmers and cms' to use. Cgi on the other hand is more powerful and flexible when you get to the advanced stuff, not saying you can't do advanced stuff in php but its a lot more difficult and time consuming and there are large limitations such as multithreading and the benefits/availability of CPAN modules. If you're going to pick the language based on the script I say go with the language that is most comfortable for you and your editing abilities, that would most likely be php.

In a nutshell : CGI either as a perl script or compiled application has the capability of doing some things only really found in desktop applications. Where as PHP is strictly interpreted by the PHP interpreter.

And speaking of interpreters, most hosting providers execute/interpret the php script via ... wait for it... a cgi executable (php5.cgi etc). True it can be compiled with Apache and run as mod_php, but some hosting providers don't do it that way because then someone could hide a very CPU heavy script behind an apache process.
 
Excellent! - thanks for the clear definitions between the two.

Yes, one program is perl with cgi extension which operates out of the cgi-bin.

Basically - these are community, cms type scripts, which have features such as, adding/deleting links and content, shopping carts, adding/deleting users, classifieds, photo galleries etc...

Both have an easy to use admin control panel - where you can organize structure, customize templates, add admins, users, DB backup, modify the site in every way -- both very well done, and easy to use - so I wouldn't really need to start rewriting their actual code. It also has a search engine to search the database and display the results in html - on the user end.

All information is stored in mySql - then the info is displayed in the browser in html.

I guess I really want to know - when the site starts to get heavy traffic and lots of simultaneous uses, using the script and performing operations - which format is more stable and efficient - less likely to slow down or crash etc.

cheers!
 
I guess I really want to know - when the site starts to get heavy traffic and lots of simultaneous uses, using the script and performing operations - which format is more stable and efficient - less likely to slow down or crash etc.

The biggest factor in this is how well the programming is for either application. If anyone tries to tell you different, they're very likely bullshitting you unless they've seen the code for both.
 
Status
Not open for further replies.