PHP Web
PHP Web
rur
Aduantage,Jitadvantogeg 7
PHP
charaeteriebies,
0Lotodudion, ovetvieu,
DecNavinq Varinbles in PHP obj.t, sou,
town
sbng Disetoaies PHP
in
StopeonHbme t a Nariable
rererna
1 onnetr database ys. as a
CH NAG ENDRA
Lhoduehom o PHP SAL
990
Suta
ode is wnten here
17
Exomple', -
ho #Al ".
"
tis Statment
's ed to
whieh
9enerat autput i >
P p
aput"H0." coweb
ends wtb Sern (oVon
phpphp Sttsrmurts
Ovevie of php'.
mbedeed
PhP a Server Side Scniding Yanquoqe
ASP.NET,
XHTML. T t an Altrnatve t hT, AsP,
there is
php make use ynacols yping that mean
no oezd to dsare Varia ble type in
php.
h ge OumbeY a r y o n s hteh maket
t PAexable develop (ode t php
php proaaso worKe n wo mo d
Oiened Pvoqacnming,
Setuion manaqernent feábrd, So
eVcoinates
nate he unnetetsary
he
menoy AJNotsho),
Setuthy
tSuppot nevyshrn rehensoSeowrhy
Tab: ven xable onguae besouse t
Con be
Con be embedded wth , Css, Javapt
XML d
mony othon yanqunge and he
dedaratro
nn
k Variabe inlewir
The value Can be Augnedo
Variable. name Va
ta
he value n Asiped»
Variabe th by
dctaul vol ULL
nd Unauigned
}his Unauiq nud
hi
Variables are Cald Uabound Valabks and
Oul yaue a ovetd t the value 0
5tample
tt"hlo aryo Arign
Volueo a Vadable
5 put Qusts
0 5
nd it
O.
Net
t mut bPoltnad wh. ng Vaiabl
ts oitaaanu
php tree
Capito ente Srnal 1.tters drty
btaople
T
a
0, A 10
both are drent
Unden tort.
Variable must
manncr
wig
enples
Stovt wth nunbun.
(3Voriabl must noE
neric Va)ues
Variab les crust lontan m pha
Spalt in he Vaiae
There skerud nob be
the name
body rput 1 5
4 1php
eke fs t{y
0oCTYPE tm
htmly
-chody
php
Avarhiolge
echo T ove
3DATOT7PESN PHP
ustd in PHP.
here are ruStalar bype that ae
Lotget yp Stalen
Booantype typs
P HP
pHP
on Speualype
Avay ompound ypes
Spedo types
4)Rea
ye.
OLntgenype
to
&sd ploying Ipteger Vales. Ttis Say
ngaehype
blonple 5
eiait.andtmt be n deurna
AintgeY muthove at least on
ond t Can be aithey positive or nagahi ve
Deule type
aapoy
Bomples tO.5
incduds thot lmpluoy
Oumb wth deto p
POnnC
hov beore
bctore ter dedrna palnt.
omple
stoigtype
Thuu is haracen datetypeinP# Fhnacker
ha berpuented hen t Pepraented uSinq
otyp
lo0ecsn charat PhpSteng
hu
Spphp Sdot GHoru teinq
Vanas l igien bJa.
A TLke phe"
who
7
olp T phe
0
Followig ore the
nnsustd o
Vanou g hendi
Sthlen (si) ength o sing
hep('shing , ng3) +hs unchoo lompares Sinqa. ondthei
htoJower r q 4) onvert charactess ln irgato wur (ase
Spa
orboth ends.t tzinq
Vau auignedto
p Stin iti
a Variable (scated whut a Val,
valu 6 NULL
aurtenaticollyaiianed a
Seirgin npidbSnvad
Vansble Can uo
+o O LL
Dample ph
S a i "
nu
Ti adh Vadump) putnul
hp
dumpi intoTmahm
abutVarbe. 1
Reaour in PH
i not an Achu datartype,
hSpecial-raauruype and
unckns
Stog f evtnu
roury ethrnol o PHP ,
objut type
we Con (reate
hp obju overttd proqsorncning yanguage
i
objuds in php. objeutsalwl ty and ths
and
ohjet
objet
(oompaunddata ype.
here
Cap.lltte
delar
o
Ststernent
an
ohju Wau we nud to ut nc
a mjelau
obj ne Myulas,
php
Ocw stVas itstJIa
ben wth. we
lan dd
Deepak Properbes ynami ca
obj- age
Sob- maks 5
output.StJ chau dyut(
non Dupak
pe(so) 21
raysS'
a Jerent Vamables
h Savinq uwu r
h t Crecin
orv Very eata
=
Arey i a
Cedbro iearype Jennt and in
n
Php we Con inuede alameocs oed type togethon
Sing rroy
There r wo yays o ree Arrays in
php
u
Sing strut Array dt
value eiretly
Assiging
Aray
aroy10, 9 0,30, 40, 5o)
Ho empty ray
an alo be (realed uing he orr y (rnstrutt.
nchen is ustd to
banple' alY
arrar Crcate Array
ed type d bmeou in the Array
weCon have
wh numerie nde
array
kT", ".E", "Oulke),
echo
Coeuke)7
P:
4hdy
4/ htmb
xamplt2 <DocyeE html
chtmls
boal
-? phe
gb:kes "KTH "llee", "Dok.");
ho
30PERATDRS N PHP-
typy
O Arithmatc operato! Increment 8 derenert sperato
Asigamnt opesotora Ritwse opereto
Logicalical opriad
Eqalty 9peeckors
lornparision opetato
h a t are
ave
ased
acd
tha
Ahmaie operátons : fhere art 5 arithonatic Opestora
madhemahe operatots thy
are
to peorm
Divislum
w.dulus
Aiqnomnt oprators Jed by Sybl
ymbal"
oPyatov Na me bample
AssianmntE
Addien Auonent
subhacken
multiphakm
Divis'm
hodidu se7. 2
ogital optyator
Used To take decisio
Ustdoperovm deiien ie,
optratov Name blample
) AND
AND
NOT
Xor
Ptrator'
ideh
(5ompavisioe opeato
L
bample
Inremnt dan perato r '
Decnment
Loment
Eomple i prormmunt
x4 potJotrnst
operator
A T
AD o 0 NOT
6larmple'
ovdh ot coleahm
Smhas hiqh
, t » r p v u a t whieh
means
proy
hich bol has Voud pro
Probyand
bihst
dority
highus 1, . lwst
+
Deweat 7 ,4
oPtxatoY Aso tiekvihy
L
,,
, ,:
,
EXPRESSIONS IN PHP
lmportantbuilngblock
P#P,
prsins
are the mast
write s an bpreshon.
aWngst anything we
hal Vlu"
a"Anthing that
a
deined
Abpresion
amen
asgnent opesato le)
opesator
hat apptovs thetd
Aoythim
san ex pressim.
s an oresion
+ s an expression
opreui
oprotorsintannt
vaue st operandby 4, whee as
opetotrs dtrmnt b y 1
Intynent pos inreenent Pr deenun pst d
ehe
euho 4 4
cchox edo f etho
exo ,
ol
11
2
yu lao-d a phrtiular
hring, Reploaan Shing
pre Ssion
angther, eCan pliE Single Sing
into macy
pasts e.
L1pp
cho
(ao) ?pass-
N PHP
SESSiOn HANDLING
Sorm
Apktaien, ynu openitd
with an
whn you
whn ou work si Knrwn
Kndun
enire prous
enre prous
ese
close ts
Ti s
hi s
and thenyou
ehanges
changes
when you Stert
aS Session
tkrrs
Knawshoyou are, B u t i n the teraet
t h e (oompater Cnd
w n you ho
+he tppliteton and doet'oot
docs'not
know
Vev
rServev
is One the wb
problem. the
wb
becauseHhe http ddrss
here
or whatE
do
State.
mentain
does o uSeY
u sY tbmne
orrnh
b y t o r 'ng
Solve this Probleern
Voviablet
Sesuten
daul Sesson
Sesson
mulbple peaes
uedoto
user
oses he browSeY. So,
are present ui use,
Variable
abrmstim abrut 0n Singye
Sesion Variables bol
and are
ja0bleto a paqas
Ssston. Stort anchon
Storbed wh
Setion a viady Stovtd
Sessorn
an thn cheeks
This
and non s St
S tatr
e te
d d hen Stont Seasirn.
then
he bginnng
pt at
Sesion.Starto
deshoyed bysnSeusi' desj
Sestion Can
and
n c t o n besnot cad an rqurnunts
p # P
>
UoSkantKor utdoun&ta stlorn Variables
ome
Knnwn
Unst setkhon['tourter')
Stovt
wnet
php
Seuien durry
jntome&
Yeauest aresrrte
Seve
vcsuurland2
wiha
Scver.
Xcspmds
id
unique
Sesi n
requestsotan t h e
Sb cquant
use Seslon
a
uSer
members
Senven
6 C o o KIES IN PHP
A looKies
it
utd idntty a
a
us.
A
A Goki o Serve embeds on
useY lampuiter
Each
i used for tratkig. purpo[e.
t wil Send the
bruwer,
wh a
(reat
and
and
Yc
Y ctrriie
evve
e
both
Can
CooKie r o yru
(ro kie Vajuej
th Stookest) mchen
A G reoted
path, dornain
Syotox Set Gke oam, yd, xpire,
optimal
ntonaien nd
and oca
aca mach'nt
machino o Krhure sture
his
tores
ultY
wb Servet
Aest fo ws berver
hen
hen n t ime browstr Sendso
Sends a rquest
ServeY ond Servu
roketournatn t
hun Send hs usen.
u se.
Iormairos ldanhty
uses that
3
Requ
ust +okiy
Sruusun
Seun
Raust
Rpme+ (ktu.
CONTROL STRUTURES IN PHP
aWous us bo lonttoV-c os o oiecahoo (ode nene ralW(odei
exuted Sequestal
Stavt
mel bon
-tSteps
FALSE
TRU E
Code exeuted
vu
Candiindtotemenes
Hennt aztions
art us
to p
battnents
Carn bona
ndbenak
Jrent nems. Tere art
bacd en
Steh Statement.
Stottentot i t u .
o (ndib'en
ode
execates So Ymron'
age : 50
Synbaw londbirn)
qe) 30
bon
ihlmd
exkubed 30
han
lode to
be sue more
is
age
ecko our
unur aga it
m o r t h a n 30
T eSteknunt Co
l ode
de
anotheY
u e and
lonetm s
Some lode a
euees
ha nd ben P r o qam',
phe
Sptax.
uttd
be
(ode to
Crodto s tue',
eud
bo
ode(rnd:bon
be s
se
Crndtm s l e
2php
Systox.
3t0")
nd?tmitue uo omorning
(osebe exeu d echo
Ase ( t 2o)
ceuttd
(odet be s true,
isfalse nd th
alse
n i g h E ! "
tho
re olu
SwHh Shtnent
Sectim
nu ltpe
choriae
Sith tttnn
Staternet
yntax' ProYan'.
SwHh ()
ed
tase Sanho)
(sde to be exeded #o:abra
break Case"red:
slour is rtd
echo your
nzlabela
(deto be eeuted brtak,
brrak
Cale "blue
is blue!".
echo" ur
tolour
Jefault braak
aho"
Nor is reen
you
rrok
i ot pru
echo yus l
tnd ti
Klonditiom
ole ed
Sbattnent
Stattrant
T r u e
Statemunbo)*
ENOF
statennt
(mdto tue.
nd:tm4 Statrnenk
Pse
mdsim ue |ndtinstaernanot
fase
Suieh
Su ndin) Statment
ue
onibm A Sbaztemunt
break
Statemernt o
lond:6on
breal
lertatn nurnber d ms
to un ovey and oveY galn
9aln a
(de n na ip
SSo tstesd dadding Severa
we ult
rops
Same blak bde
ex.eeutehe
Noops aveed
is tue
aga'nand agan
aqaln oong a a
a a Cetadn (nd:Sm
ops
oops are cleukhd oto our typ
wlile
do hil
toreach
hoopt ute +he Llk 6de asleng
the Speuk lond:tiro k tru
ecoTke unber is 2b
+
outp 1,2,3,,
dohile lope thrmugh a blodk odJ one, and hn epeass the
Nrvp as ng al dhe Spedke ndtion s tee
Prograr.
Sba phe
4
Comd:tmto be oceuted
ch T number i k
k:lendHn urue)), 44
th nmbe is
fInurtet
taut unt; htment lnuter
d dach terabon
ode
lample Lph
oupus
io
h elh
rmpa b k (ode
nan aTaY
sed o lovo
d ls
or aath Deop iagks onky on
thvgh eas KValue po'r in an ara
Sotox
1phe
tlors avrayred, qrun
aand valu blu ye0lrw)
olp red
9ren
blu
Jelln
0pen()
ANe ope
s ded Jo open kJe. t takay
PHPopent)unhen
wo parameters .
J .on
unch node
which mode
ontainu name4be to be opened includes in
e ghal be opentd
blample' phP
4.openP.ut, ) ;
1
a Append
pde 14 read on at aad/ppend
w t nly
+ read write
(
(ontett daba are
ar
A e u opened ngfopent) he
ead ing Pzeadt .
bake Joo oqumot ogumtnte
parinkey to .
New e ov
mo des4
W, t , wt , , t+
1)Sset ).
Flei Joed doset) -unchm. 1ts arq ument:
h nuds Jaed.
Jample Pole(A)
U.lak
Ad .lete he 5em one parameer Ateptd le
e nom Btample Untak( Hl)
JLeted t dhplay T2vE se t Pehu
.
UPLOADS:
9 HANDLING FILE
and ubpk l e through fw ne
PtHP a s you to upload Sle
Coede binary and and
ollort u upload
PHe upload feater
lan have the o
mortoe, yu
PHP FILES
tains he ormakn l e, h
The PH qlbot.PLES
we Can qer noma, AHpe, kl.se
nLE
assocattd wh Rle.
temp 4le rame
ond erovs
Kle is ename,
i this example, we are a uming t e name
tere, o
MIMEHR
Innub mal extnsirn)
(multipupoje
Si3e
.FuEsna 3-,
tempor
FuESAoan p emot asodabed
cheks uploade+hmuah
ftn
t onovthe l
aquc
post Raques
OR FORM CoNTROLS
CONTROLS
FORM
HANDUNG
. FORM
Jov S PUP
PHP.
use Jorms
(reate and use to use
eed to use
ww
e e
(an
we
oed
n th o r ,
the data present
To get
'are
bals.They Uedto (olleet
PHP Spero Germethod
nET mthod
Jorm daba
g-GET
em e PoST Method
geb nched
toieve
esata
by sing
To Pab
btrnk
PHP Post ovn
ide ued to
Post uest S.mton hdt ove
orge amount daba Sueh a onds irnnge upload
ogin formS, tgishatn' orrms
The data passed hugh Post
post sequest not Visible on the
URL bwwseYSo t a Seured y lan Send arge
a t a hraug Postequest
in
ASimple oample to yeevee ata rorn post Post
uest
php
methedPost"
ethon Dab. php
addres is
yuY mai
-php
echoPoST "
N a m e! T S a i
Em nsai3o5dolm
Sa
wkior Sai
is
ou &nal addreu
nsi 3osqnil (on
Cnet Pequ
he detauls om Pegus. [he
his
vis:ble o
Palsed mugh qet auut s
NameSai
Dataph / .
[email protected]
L body
wlcorne
Lphp welem Sal
echo g e t "ame ourena acdress is
oSa 205@no. o
uy emal address is
php
eho $qet
Lbody
htmly
11. LisTIN DIRECTORIES
furckont thab o ous
PHH Prnvides Support
a ofdreetory
and
and is
dredoriu
etsieve ifomatian abou
(ontents
uocbom
descxiption
hraokc)
Wove Current worKing distory
ese die
gecwde Reburo
open drutory handle
open dirt
Yad aty
an
ectory
Yewnddit l) Rese divutony hand le.
Reurns an
Instante t he direeony has
Thedirecto Junchons
ave part t PHP Co
No Insta llatirn ssquired to use these funchons
theopn on d
Yead are the wo imporant
inportant
prs
Funthons that are
lomoony usedh. Qstion
ontents aira
Paramete
open eir Syata open dir pah, Gotest);
Read dhe
Synta'. enddi handle)
Oprtion oX paramete
handle xeiruru
t deroter drty
hich b opened wHh opendi
oal vaviables
3) Statbc here in the
oalVariader Can be acessed anyw
obalVariabkt ln afuncion,
it mast
Jo acceu
Prog Yar uSing
derkeraben suncbie
be darlared th a qobl
qlobal Kyword. othorwle the Vayialle aets aS
oca Vaiable
i e n Sun) Stabe
y u want
1
ctime of Vaxiable
in php-unctianbgin when
e 1: me acalVaviable
ends when e Punebeo execuhon
Variable i a t t d and e
anetion ese
afunebieneie eeuchon
is ter temnatio
tevo inates
e rousand (amns. we
Can
an 9uerya
ara nqed
arra nqt in
a equestr a question
Parbcula itovmabon. uery it
to yctaieve
or database.
and t
hes
anguage
PHP is a
Server s:de Striphirg traturd
Culstomedrstura
lustoid
ot
P a e s 'oith
kighSeccure.
PHP-MySQL are Stable technolagies and have Cross plattom
+hese
Capab Hence he w oplicakon daveloped uing
tehnolagiet berome portable.
Otaehok
()wordpres
iikt peda
ahvo
s usedto establih (onnecbon
7Mys_ (onnett)Junekon a
tuntions to My SQL
ust
to (cate daba baSt 'fancion
for eors .in (ommandS mysaeor()
mySeleub.dk
Selecing dababase
stng Databest
O (reabe a kable