Results 1 to 29 of 29

Thread: What is the difference between PHP and CGI (perl)? Which is best and Why?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982

    What is the difference between PHP and CGI (perl)? Which is best and Why?

    The subject says it all really.
    I am attempting to delve deeper into web server technologies and was wondering what the difference between PHP and CGI (perl) is and which you prefer and why?

    Thanks


    Things I do when I am bored: DotNetable

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629
    PHP was originally built from Perl, so there is a lot of similiarity between the syntax of both languages. Rasmus Lerdorf (the creator of PHP) originally made up PHP (then known as "Personal Home Page") as a group of Perl scripts that tracked visitors to his website.

    PHP was designed to be used with web applications, while Perl was more designed towards system-scripting. Essentially, Perl is the more powerful language and preferred for system-scripting, although PHP can also be compiled as a module and be used for system-scripting. For me, for web scripting I'd choose PHP, and for system-scripting I'd choose Perl. With PHP, you have great flow controls and file pointers for efficient file input and output, but that's only good for the web. Both languages can be more efficient for you, but it will all depend on what you are planning to do. Perl for system, PHP for web.

    I started using Perl in '98/'99, and up until around the start of May of '03 that's the only server side language I had dipped into. I had used Perl for all sorts of web development, and made many 1000+ line programs that worked fine. After that, I started learning PHP, and have left Perl behind. Perl is complex, and to make a simple script it could take 40 lines, while a PHP script that does the same thing would take less than 10. When I was looking back at some of my old Perl scripts, I decided I'd remake one, and although I half quit doing that because I lost my inspiration, I had found that by doing it in PHP I would have more functionality with less code used, and less of a load on the server since when using PHP I used several PHP scripts instead of, in Perl, using one 1500+ line script. So, PHP is a faster language in web development.

    Hope that helps you a bit.. and I hope I didn't confuse you on anything. I might have some of the information wrong in it, I went mostly off of the top of my head and off of a site I have.

    Read more about the differences here: http://code.box.sk/newsread.php?newsid=213
    Like Archer? Check out some Sterling Archer quotes.

  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Search the forums. This has been asked (and debated (in blood)) many times.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    Thanks Kows, that explained it very well, you didn't confuse me.

    Hobo, to be honest with you I forgot to search the forum. I will do that now.


    Things I do when I am bored: DotNetable

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    I understand the comparison between PHP and CGI is a very live subject but how does it all relate to ASP.

    We are in the process of moving to ASP.NET, (I am going on some training next month). I have used ASP2 a little. If I am using ASP.NET properly do I even need to use a scripting language like PHP or CGI.
    AS PHP pages require a file extension of PHP then that throws mud in the eye of using ASP doesn't it. You can't then have a file extension of ASP.

    I understand you can have PHP embedded in your page but can you call PHP script files like you can with CGI.

    I did search the forum but found no mention of ASP in the PHP forum. Maybe that is the answer my question about how ASP and PHP relate to each other.


    Things I do when I am bored: DotNetable

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    That's because ASP and PHP are competing technologies.

    There are many ways to do dynamic pages.

    1) PHP. Open Source project, free, runs on Windows (IIS and Apache), Linux (Apache) and maybe some other *nix platforms. Scripting in PHP.
    2) Servlets/JSP. Open standard by Sun, essentially free. Runs everywhere there is a Java Virtual Machine. "Scripting" in Java.
    3) ASP. Microsoft's proprietary technology. Runs only under IIS. There are some porting projects, but because ASP is so geared toward Windows, they are limited. Scripting in JScript or VBScript.
    4) ASP.Net. Successor to ASP. Runs under IIS with .Net installed, but to a certain extent also under the Mono project. Scripting in any .Net language, usually C# or VB.Net.
    5) CGI. International standard. Supported by virtually every server there is, with the exception of a few miniservers. Because of its architecture, it's usually slower than other technologies. "Scripting" is done in anything the OS supports. It can be scripts that are run by an interpreter (e.g. Perl). It can be real executables. I wrote a tiny CGI script in Assembly once in school.

    There are more technologies, but these are the most popular. Each has its advantages and disadvantages. But one thing is sure: unless you absolutly have to, don't use ASP. If you want to use an MS technology, use ASP.Net.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    We will be using ASP.NET that is a management decision.

    Learning PHP or CGI will be a personal spare time achievement.

    Thanks.


    Things I do when I am bored: DotNetable

  8. #8
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    What is the reason why management mandated ASP.Net? What kind of work do you do?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    What is the reason why management mandated ASP.Net?
    Death threats from MS

    Learn the theory of CGI, then PHP.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    I work for a local college in the Information Systems department.
    We publish data via web browser, so usually its basic stuff.
    We also write in house applications for the admin staff, student records etc.

    Everyting is basically microsoft.


    Things I do when I am bored: DotNetable

  11. #11
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by davidrobin
    I work for a local college in the Information Systems department.
    We publish data via web browser, so usually its basic stuff.
    We also write in house applications for the admin staff, student records etc.

    Everyting is basically microsoft.
    Once you work your way into upper management, remember that microsoft = $$.

    Unless you're heavily into other Microsoft products and need ASP to interact with them somehow, I see no reason why PHP would work for your needs.

    Unless I'm mistaken, Windows costs money, IIS costs money, and ASP costs money.

    Linux is free, Apache is free, PHP is free, and MySQL is free.

    Remember that when you get in that high seat.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  12. #12
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I see no reason why PHP would work for your needs.
    I don't either

    Upper management in a local college?


    Remember this too:
    MySQL runs in Windows, Apache runs in Windows, PHP runs in Windows. Later, when you switch to the definitly better server OS, you don't need to change a single line of code.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  13. #13
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Er, make that "wouldn't"
    My evil laugh has a squeak in it.

    kristopherwilson.com

  14. #14
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  15. #15
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by CornedBee
    My evil laugh has a squeak in it.

    kristopherwilson.com

  16. #16

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    I have taken everything you have said and acted on it.
    As a sign of protest against Upper management and microsoft I resigned today.



    Only joking!!!

    For the last few days I have been trying to find a decent web server that I can install on XPHome. I avoided Apache originally because I wanted on with a nice GUI interface.

    Anyway yesterday I successfully installed (after 3 attempts) to install Apache. This is so I can do my personal web development. I will not be using it as a live web server so security is not an issue at this stage. I will have to learn it in time. I did notice there is a gui project ongoing.

    I am also about to install ActivePerl, PHP and MySQL.
    This, I am hoping will give me the chance to learn som of the REAL WORLD web development technologies rather than being tied down to microsoft technologies.

    Unless I'm mistaken, Windows costs money, IIS costs money, and ASP costs money.
    I have noticed that Linux hosting is cheaper than Microsoft, this in itself is reason not to go with microsoft (The resistance grows stronger).


    Things I do when I am bored: DotNetable

  17. #17
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Does IIS have a graphical interface?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  18. #18

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    It does,

    but as I don't have XP pro at home I cannot install it.


    Things I do when I am bored: DotNetable

  19. #19
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Who needs a graphical interface anyway? Waste of resources if you ask me.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  20. #20
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Why want a graphical interface? I like Apache where I can just run it and never see it until I shut it off.

    MySQL for Windows has an interface (WinMySQLAdmin or something), and that's a poorly written application, IMO.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  21. #21
    Fanatic Member Graff's Avatar
    Join Date
    Jan 2002
    Location
    Calgary
    Posts
    668
    I like gui interfaces because I'm somewhat of a dyslexic typer, command line stuff gets me mad


    I like to dabble in all sorts of languages,servers, databases etc so I don't limit myself. I tend toward the microsoft side of things simply because they are the dominate power in corporations. Why? Management is stupid, they want something familiar something with a big brand, they feel the more money you spend on something the better it is and simply because they're not aware of the alertnatives.

    Don't get me wrong, apache is great, but it's a little more than annoying to set up at times, I remember the frustrations of doing it more than once, where IIS is all click next click next blah blah there you go. Not to mention on IIS I can run PHP (my new favorite), ASP, ASP.NET, CGI/PERL, etc (its kind of a piss off that microsoft not only hordes their scripting laguages but they support the guys trying to make it available, but that's life I guess).
    If wishes were fishes we'd all cast nets.

  22. #22
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Apache for me was
    "Agree to the license?"
    "Where to install it?"

    Done.
    Even compiling it on my own PC was a snap.

    Though I admit I didn't install PHP with it.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  23. #23
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    PHP was a little confusing to install with Apache, but I would say it was far from "hard". www.php.net tells you exactly how to install it.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  24. #24
    Fanatic Member Graff's Avatar
    Join Date
    Jan 2002
    Location
    Calgary
    Posts
    668
    you know what, I'm getting apache and mysql confused.
    If wishes were fishes we'd all cast nets.

  25. #25
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    ***? One is a web server. The other is a database.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  26. #26
    Fanatic Member Graff's Avatar
    Join Date
    Jan 2002
    Location
    Calgary
    Posts
    668
    I use mysql heavily with a lot of websites I develop so I install apache and mysql on a lot of servers at the same time.
    If wishes were fishes we'd all cast nets.

  27. #27

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    Are these windows or linux servers?
    Do you have a set installation document you follow or do you do it from memoruy?


    Things I do when I am bored: DotNetable

  28. #28
    Fanatic Member Graff's Avatar
    Join Date
    Jan 2002
    Location
    Calgary
    Posts
    668
    windows mostly, done from memory
    If wishes were fishes we'd all cast nets.

  29. #29

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    I was asking because it is interesting to know how other people install and configure apache, mysql as I have done it for the first time and probably rather hap-hazzardly. A little tweak here and there after asking questions.
    How secure it is I don't know. I think its OK. As it is on my own machine and not networked I don't need to worry too much, its just good to know.


    Things I do when I am bored: DotNetable

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width