php Programming for absolute beginners
Tale of Cotets
Itroductio
Php or php hypertext Preprocessor is a prograig laguage, which was desiged with the oective to allow creatio of dyaic cotet. oreover, php also eales this dyaic cotet to iteract with dataases. As a result, the ost ituitive applicatio of php is for developet of we-ased software applicatios. This ook is a itroductory tutorial to help you lear php fro scratch ad uild the right foudatio for advaced lessos i this prograig laguage.
Although, this tutorial does ot require the reader to have ay prior kowledge of php or ay other prograig laguage, asic kowledge aout prograig cocepts is recoeded. esides this, cosiderig the fact that php allows iteractio with dataases, you ca expect to ecouter dataases oce i a while. Therefore, soe ackgroud kowledge ad uderstadig of dataases ad SQL will also e of iese help.
This ook icludes several saple codes, which have ee provided to give you the real-world prograig experiece. go ahead ad execute these codes for a etter learig experiece. esides this, you ay also try variatios of code ecause the est way to lear a prograig laguage is y writig progras i it. We wish you a fruitful experiece. happy codig!
Copyright 2017 - All rights reserved.
This docuet is geared towards providig exact ad reliale iforatio i regards to the topic ad issue covered. The pulicatio is sold with the idea that the pulisher is ot required to reder accoutig, officially peritted, or otherwise, qualified services. If advice is ecessary, legal or professioal, a practiced idividual i the professio should e ordered.
- Fro a declaratio of Priciples which was accepted ad approved equally y a coittee of the Aerica ar Associatio ad a coittee of Pulishers ad Associatios.
I o way is it legal to reproduce, duplicate, or trasit ay part of this docuet i either electroic eas or i prited forat. Recordig of this pulicatio is strictly prohiited ad ay storage of this docuet is ot allowed uless with writte perissio fro the pulisher. All rights reserved.
The iforatio provided herei is stated to e truthful ad cosistet, i that ay liaility, i ters of iattetio or otherwise, y ay usage or ause of ay policies, processes, or directios cotaied withi is the solitary ad utter resposiility of the recipiet reader. Uder o circustaces will ay legal resposiility or lae e held agaist the pulisher for ay reparatio, daages, or oetary loss due to the iforatio herei, either directly or idirectly.
Respective authors ow all copyrights ot held y the pulisher.
The iforatio herei is offered for iforatioal purposes solely, ad is uiversal as so. The presetatio of the iforatio is without cotract or ay type of guaratee assurace.
The tradearks that are used are without ay coset, ad the pulicatio of the tradeark is without perissio or ackig y the tradeark ower. All tradearks ad rads withi this ook are for clarifyig purposes oly ad are the owed y the owers theselves, ot affiliated with this docuet.
Chapter 1: overview
The first versio of php was a sall ope source proect that was iitiated y Rasus Lerdorf. This versio of php was released i the year 1994 ad it was after this release that php really picked up as a laguage of choice for prograers all over the world. It is this growig popularity of the laguage that has coverted this sall proect ito a proect of world-wide recogitio.
efore ovig ay further, let us look at a few facts aout php. Firstly, php is a recursive acroy that stads for php: hypertext Preprocessor. asically, it is a scriptig laguage for server-side prograig. The scripts are eedded ito htl code ad ca e used to aage dataases, dyaic cotet ad sessio trackig. Oe of the ost popular applicatios of php is i the developet of e-coerce wesites.
The fact that php allows aageet of dataases is oe of the key features of this prograig laguage. To support this, php allows sealess itegratio with ay dataases like icrosoft SQL Server, Iforix, Syase, oracle, ysql ad postgressql. Perforace-wise, php is literallu zippy i zits executio. This is all the ore true for scripts that are copiled i the for of Apache odule o Uix side. Upo startig, the ysql Server ca execute the ost coplex queries i record-settig tie.
ulti-tier developet, which is the eed of oder prograig, has ee ade possile y php. Php4 supports distriuted oect architectures (cora ad co) ad ava. esides this, it also supports a variety of protocols like ldap, IAP ad pop3. Lastly, php is oe of the ost forgivig laguages you will ever use ad shares excessive siilarities with the c prograig laguage as far as sytax is cocered.
Characteristics ad Uses
Soe of the key uses of php iclude
Supports easy hadlig of fors, allowig data gatherig, data savig o the file, sedig data via eail ad returig data to the user.
Supports executio of syste fuctios like opeig, creatig, deletig ad writig oto files o the syste.
Supports dataase operatios like addig, odifyig ad deletig eleets iside the dataase via php.
Allows access ad settig of cookies.
Allows placig of restrictios o soe pages that ca e set y the prograer as iaccessile for the user.
Allows data ecryptio.
Php has five key characteristics aely flexiility, efficiecy, security, siplicity ad failiarity.
First php Progra
To start with, let us look the at the siplest php script ad try to uderstad how the sae is workig. This script prits the strig hello World! o the scree. As we have already etioed, php scripts are eedded i htl. What this eas is that php stateets are writte iside oral htl code. Saple code is give elow for your referece.
Upo executio, this code yields the followig result.
As you ca see i the saple code, the we rowser does ot output the php code as it is. Istead, it processes the code ad what we get o the rowser of the cliet scree is pure htl output. Php code ca e itegrated with htl usig oe of the three ways illustrated elow
Php code goes here ?>
php code goes here
Usig oe of the forats show aove, you ca put php code i htl. This tells the parser that the text preset i this forat is php script, which eeds to e executed. The cooest tag used for php itegratio with htl is Php ?>.
Eviroetal Setup
Evidetly, php rus with htl i the we rowser ad to test php code, you will eed to set up a local syste. I order to ru php scripts as part of your htl i the we pages, you require three copoets to e istalled o your local syste. These copoets iclude
We Server
You ca use ay we server ad rest assured that php will work with it. Therefore, if you are workig o a Widows syste, you ca safely work with the icrosofts Iteret Iforatio Server (IIS). With that said, the Apache reais the ost popular server for php ecause of its ope source ature.
dataase
Likewise, php ca e used with ay dataase solutio, which icludes popular dataases like Syase ad oracle. however, the solutio that is ost cooly used is ysql.