Ergaleio diasundeshs me to WWW
To palio onoma einai Professional Home Pages (PHP 3) kai to neo onoma einai PHP Hypertext Pre-ProcessorGia erwthseis, steilte e-mail sto :
To PHP 3 einai mia scripting glwssa gia thn PostgreSQL h opoia enswmatwnetai se html kai ekteleitai sto Server. Sas epitrepei na grafete apla scripts sta arxeia .HTML paromoia me thn JavaScript, mono poy anti8eta me thn JavaScript, to PHP 3 den ejartatai apo to browser. To JavaScript einai mia glwssa h opoia enswmatwnetai se html kai trexei sto client-meros enw to PHP 3 ekteleitai sto Server. To PHP 3 einai paromoio sthn sullhch me to proion ths Netscape LiveWire Pro. An exete ta apaitoumena xrhmata, kai trexete ton emporiko Server ths Netscape kai exete ena apo ta yposthrizomena leitoyrgika systhmata, isws 8a prepei na rijete mia matia sto LiveWire Pro. An sas aresei to dwrean, taxutata anaptyssomeno logismiko poy erxetai me olo ton phgaio kwdika pi8ana na sas aresei to PHP 3.
Yposthrijh stantar CGI, FastCGI kai Apache module. San ena stantar programma CGI, to PHP 3 mporei na egkatasta8ei se opoiadhpote mhxanh Unix kai na trejei se opoiodhpote Unix web server. Me thn yposthrijh toy neoy stantar FastCGI, to PHP 3 exei to pleonekthma twn beltiwsewn sthn taxuthta poy ofeilontai se ayto to mhxanismo. San Apache module, to PHP 3 ginetai ejairetika isxyro kai tromaktika grhgorh enallaktikh toy programmatismou se CGI.
* Megala kommatia aytou toy kwdika anaptux8hkan sto kai gia to Panepisthmio toy Toronto. Polles eyxaristies ston Lee Oattes toy Tmhmatos Anaptyjhs Diktuwn toy panepisthmioy gia tis synexeis epoikodomhtikes kritikes toy.
* O kwdikas yposthrijhs ths PostgreSQL grafthke apo ton Adam Sussman
* Anari8mhtoi alloi, boh8hsan sto na elegx8ei kai na aposfalmatw8ei to paketo.
To PHP jekinhse thn zwh toy ws cgi kwdikas epikalychs (cgi wrapper) grammenos se Perl. Den proorizotan gia tipota pera apo proswpikh xrhsh. To onoma toy prwtoy aytou paketoy htan Personal Home Page Tools, kai argotera egine Personal Home Page Construction Kit.
Grafthke ena ergaleio gia na enswmatwnei eukola erwthseis SQL se web selides. Htan basika ena akoma CGI wrapper poy metefraze erwthseis SQL kai ekane thn dhmioyrgia formwn kai pinakwn apo tis erwthseis mia eukolh ypo8esh. To ergaleio ayto onomasthke FI (Form Interpreter).
To PHP/FI ekdosh 2.0 einai ena eniaio programma, ej'oloklhroy janagrammeno, poy apotelei ton syndyasmo twn duo parapanw paketwn. Exei twra pia ejelix8ei se shmeio poy einai mia aplh programmatistikh glwssa enswmatwmenh se arxeia HTML. To arxiko akrwnumio, PHP, emeine. Den einai kan antiproswpeytiko pia. To PHP/FI xrhsimopoieitai perissotero apo oloklhra web sites shmera, para gia mikres egkatastaseis Proswpikwn Selidwn (Personal Home Page). Me opoio onoma, ejaleifei thn anagkh gia ta polyari8ma mikra Perl cgi programmata, epitrepontas sas na balete mikra scripts apey8eias sta HTML arxeia sas. Ayto epitaxunei thn olikh taxuthta twn web pages sas, mia poy h ka8ysterhsh toy klwnismou (forking) ths Perl se pollapla antitypa exei ejaleif8ei. Kanei epishs eykoloterh thn diaxeirish megalwn web sites topo8etwntas ola ta systatika mias web page se ena mono html arxeio. Enswmatwnontas yposthrijh gia diafores baseis, kanei thn anaptyjh selidwn-me-dynatothtes-xrhshs-bashs tetrimmenh. Polloi briskoyn thn enswmatwmenh fush toy programmatos polu eykoloterh para to na prospa8oun na dhmioyrgoun jexwrista arxeia HTML kai CGI.
Kata th diarkeia ayths ths tekmhriwshs, ka8e anafora sto PHP, FI h sto PHP/FI milaei gia to idio pragma. Oi diafora metaju toy PHP kai toy FI einai mono 8ema antilhchs. Kai ta duo xtizontai apo ton kwdika ths idias dianomhs. Twra to PHP/FI metonomasthke se PHP 3.
To prwto pragma poy 8a parathrhsete an trejete mia selida mesw toy PHP/FI einai oti pros8etei ena footer me plhrofories sxetika me ton ari8mo prosbasewn sth selida sas (an exete metaglwttisei thn katagrafh prosbasewn sto ektelesimo). Ayto einai ena polu mikro deigma toy ti mporei na kanei gia sas to PHP/FI. Paizei ton ejisoy shmantiko rolo toy metafrasth cgi se formes, apo ekei bgainei kai to FI meros toy onomatos. Gia paradeigma, an dhmioyrghsete mia forma se mia apo tis web selides sas, xreiazeste kati gia na epejergastei thn plhroforia se ayth th forma. Akomh kai an apla 8elete na perasete plhroforia se mia allh selida, 8a prepei na xrhsimopoihsete ena programma cgi gia na to kanete ayto. To PHP/FI kanei ejairetika eukolo to na parete dedomena apo mia forma kai na kanete kati me ayta.
As ypo8esoyme oti exete mia forma:
<FORM ACTION="/cgi-bin/php.cgi/~userid/display.html" METHOD=POST>
<INPUT TYPE="text" name="name">
<INPUT TYPE="text" name="age">
<INPUT TYPE="submit">
<FORM>
To arxeio display.html 8a mporouse na periexei kati san to parakatw:
< ?echo "Hi $ name, you are $ age years old!<p>" >
Einai toso aplo! To PHP/FI dhmioyrgei aytomata mia metablhth gia ka8e
input field sth forma sas. Mporeite tote na xrhsimopoihsete aytes tis
metablhtes sto arxeio ACTION URL.
To epomeno bhma afou exete katalabei pws na xrhsimopoieite tis metablhtes einai na jekinhsete na paizete me merika tags logikhs rohs stis selides sas. Gia paradeigma, an 8elate na emfanisete diaforetika mhnumata basismena se kati poy eisagei o xrhsths, 8a xrhsimopoiousate th logikh if/else. Sto parapanw paradeigma, mporoume na emfanisoyme diaforetika pragmata me bash thn hlikia poy edwse o xrhsths allazontas to arxeio display.html ws ejhs:
<?
if($age>50);
echo "Hi $name, you are ancient!<p>";
elseif($age>30);
echo "Hi $name, you are very old!<p>";
else;
echo "Hi $name.";
endif;
>
To PHP/FI parexei mia polu isxyrh scripting glwssa poy 8a kanei polu perissotera
ap' oti kanoyn ta parapanw apla paradeigmata. Deite to tmhma sto
"PHP/FI Script Language" gia perissoteres plhrofories.
Mporeite na ka8orisete epishs sto PHP/FI poios epitrepetai na exei prosbash stis selides sas. Ayto epitygxanetai me mia enswmatwmenh o8onh ru8mishs. Me ayth 8a mporousate gia paradeigma na ka8orisete oti mono ta atoma apo sygkekrimena domains 8a mporoun na doyn tis selides sas, h 8a mporousate na dhmioyrghsete ena kanona poy 8a prostateye merikes selides sas me kwdiko. Deite to tmhma "Elegxos prosbasewn" gia perissoteres plhrofories.
To PHP/FI einai epishs ikano na dexetai uploads arxeiwn apo opoiodhpote web browser symbato me RFC-1867. Ayto to xarakthristiko epitrepei se an8rwpoys na anebasoyn kai text kai binary arxeia. Me ton elegxo prosbasewn toy PHP/FI kai tis logikes synarthseis, exete plhrh elegxo panw sto poios epitrepetai na anebazei (upload) arxeia kai ti mporei na kanei me to arxeio afou to anebasei. Deite to tmhma "File Upload" gia perissoteres plhrofories.
To PHP/FI yposthrizei to paketo bashs dedomenwn PostgreSQL. Yposthrizei enswmatwmenes SQL erwthseis sta .HTML arxeia sas. Deite to antistoixo tmhma sthn "Yposthrijh ths PostgreSQL" gia perissoteres plhrofories.
To PHP/FI yposthrizei epishs kai to paketo bashs dedomenwn mysql. Yposthrizei enswmatwmenes SQL erwthseis sta .HTML arxeia sas. Deite to antistoixo tmhma sthn "Yposthrijh ths mysql" gia perissoteres plhrofories.
Enas kalos tropos na trejete to PHP/FI einai xrhsimopoiwntas ena cgi redirection module me ton Apache server. Parakalw shmeiwste oti de xreiazetai na anhsyxeite gia modules anakateu8ynshs an xrhsimopoieite thn ekdosh toy Apache module toy PHP/FI. Yparxoyn duo apo ayta ta modules anakateu8ynshs dia8esima. Ena apo ayta anaptux8hke apo ton Dave Andersen
kai einai dia8esimo sto kai to allo erxetai paketo me ton Apache kai legetai mod_actions.c. Ayta ta modules einai ejairetika paromoia. Diaferoyn elafra sth xrhsh toys. Kai ta duo exoyn testaristei kai doyleuoyn me to PHP/FI.Deite thn tekmhriwsh toy Apache gia to pws mporeite na pros8esete ena module. Genika, pros8etete to onoma toy module se ena arxeio poy onomazetai Configuration. H grammh poy prepei na pros8esete an 8elete na xrhsimopoihsete to module mod_actions einai:
Module action_module mod_actions.o
An xrhsimopoieite to module mod_cgi_redirect.c pros8este ayth th grammh:
Module cgi_redirect_module mod_cgi_redirect.o
Sth synexeia, metaglwttiste to httpd kai egkatasthste to. Gia na ry8misete to cgi redirection xreiazetai eite na dhmioyrghsete ena neo tupo mime sto arxeio sas mime.types eite na xrhsimopoihsete thn entolh AddType sto arxeio sas srm.conf gia na pros8esete ton mime tupo. Gia na pros8esete ton tupo mime 8a prepei na exete kati san to parakatw:
application/x-httpd-php phtml
An xrhsimopoieite to module mod_actions.c, xreiazetai na pros8esete thn
parakatw grammh sto arxeio sas srm.conf :
Action application/x-httpd-php /cgi-bin/php.cgi
An xrhsimopoieite to mod_cgi_redirect.c 8a prepei na pros8esete thn
parakatw grammh sto arxeio srm.conf :
CgiRedirect application/x-httpd-php /cgi-bin/php.cgi
Mhn xrhsimopoihsete taytoxrona kai ta duo mod_actions.c kai mod_cgi_redirect.c.
Afou exete egkatasthsei ena apo ta cgi redirection modules kai ta ry8misete swsta, 8a mporeite na prosdiorisete oti 8elete ena arxeio na ginei parsed apo to php/fi apla allazontas to extension toy arxeioy se .phtml. Epipleon, an pros8esete ena index.phtml sth grammh DirectoryIndex toy arxeioy sas srm.conf, tote h top-level selida ston katalogo 8a ginei aytomata parsed apo to php an to index arxeio onomazetai index.phtml.
Mporeite na anakatey8unete aytomata tis aithseis gia arxeia me sygkekrimenh katalhjh arxeioy wste na ta xeiristei to PHP/FI me th xrhsh toy Netscape Server CGI Redirection module. Ayto to module einai dia8esimo sto "File Archives" sth selida toy PHP/FI. To arxeio README poy yparxei mesa sto paketo ejhgei ka8ara pws na to ry8misete gia xrhsh me to PHP/FI.
O NCSA den yposthrizei pros to parwn modules, kai etsi gia na kanoyme anakateu8ynsh cgi me ton server ayton, 8a xreiasteite na tropopoihsete ton kwdika toy server sas. Mia dior8wsh/mpalwma (patch) poy to kanei gia ton NCSA 1.5 diati8etai sta arxeia toy site toy PHP/FI.
An xtisete th CGI ekdosh toy PHP/FI, mporeite na to xrhsimopoihsete apo th grammh entolwn apla grafontas: php.cgi filename opoy to filename einai to arxeio poy 8elete na kanete parse. Mporeite na dhmioyrghsete epishs standalone PHP/FI scripts grafontas sthn prwth grammh toy script sas to ejhs:
#!/usr/local/bin/php.cgi -q
To "-q" apagoreuei thn ektupwsh twn HTTP headers. Mporeite na afhsete ejw ayth
thn epilogh an 8elete.