CGI ဆိုတာ common gateway interface လို႔ေခၚပါတယ္။ သူ႔ကို အဓိကအားျဖင့္ web browser မွ request ေတြကို လက္ခံေပးဖို႔နဲ႔ server side programming ေတြရဲ႕ response ကို ျပန္ေပးပို႔ေပးဖို႔ သံုးပါတယ္။
CGI ဆိုတာ ဟာ programming language တစ္ခုမဟုတ္ပါဘူး။ ဒါေပမယ့္ ဘယ္ programming နဲ႔မဆို CGI script ကိုေရးလို႔ရပါတယ္။
အခုေခတ္မွာေတာ႔ CGI ဟာ အရမ္းေဟာင္းသြားျပီျဖစ္ပါတယ္။
PHP ကို စတင္ ဖန္တီးခဲ႔တဲ႔ Rasmus Lerdorf ဟာလည္း သူ႔ personal homepage ေလးကို ျပင္ဆင္ထိန္းသိမ္းႏိုင္ ဖို႔အတြက္ CGI script ေတြကို C language နဲ႔ေရးခဲ႔ပါတယ္။အဲဒီေနာက္ ပိုမို ေကာင္းမြန္လာျပီး သီသန္႔ programming language တစ္ခု အျဖစ္ဖန္တီးလာခဲ႔တယ္။
| Task | ||
| Handle forms | ||
| Create almost anything non-static that needs to be on a Web page | ||
| Handle imagemaps | Yes (but only with client side imagemapping) | |
| Add searching to a Web page or set of documents | ||
| Create forms | ||
| Create platform-independent documents | ||
| Create applications such as chat rooms, voting booths, or anything interactive | ||
| Allow pages to be generated on the fly, making it easier to update a group of pages | ||
| Create documents tailored specifically to each user |
Listing 1.1. How to print CGI environment variables in Perl.
#!/usr/local/bin/perl
#Just returns an HTML Page with the words "Hello World" require "cgi-lib.pl"
print &PrintHeader;
print "<TITLE>Hello World</TITLE>"
print "Hello World<P>"
print &PrintEnv;exit;
#!/usr/local/bin/perl
#Just returns an HTML Page with the words "Hello World" require "cgi-lib.pl"
print &PrintHeader;
print "<TITLE>Hello World</TITLE>"
print "Hello World<P>"
print &PrintEnv;exit;
Listing 1.2. How to print CGI environment variables in C.
#include <stdio.h>
#include "html-lib.h"
#include "cgi-lib.h"
int main()
{
html_header();
html_begin("Test CGI");
h1("CGI Test Program");
printf("<hr>\n");
h2("CGI Environment Variables");
print_cgi_env();
html_end();
return 0;
}
Listing 1.3. How to print CGI environment variables in C++.
#define _DEBUG_DUMP_
#include "a_cgi.hpp"
main ()
{
ACGI acgiOut;
acgiOut.mimeHTML();
acgiOut.cgiEnvironmentDump(0x1); //a_Full dump!
return 0x0;
}
EmoticonEmoticon