0 ratings 0% found this document useful (0 votes) 25 views 8 pages PHP Question Bank
The document discusses various aspects of PHP programming, including data types, arrays, control structures, and functions. It explains indexed and associative arrays, as well as the use of control statements like if-else and loops. Additionally, it highlights PHP's performance, scalability, and compatibility with multiple databases.
AI-enhanced title and description
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here .
Available Formats
Download as PDF or read online on Scribd
Go to previous items Go to next items
Save Php Question Bank For Later nm
| ise
al 1) _b co \ean
2? To teger
13) fioat
La) SEC ng
an~
Nefine
= po
attay
atfay
| valves to
= ex. <2 PhP
$ atfay —Fruits
| &?
lerite syntax
Foreach (Sartay
to
=> |
| code
g
4
2|
Lwhak tg Mea
= TaPecasting
Natiable
exPiicity-
PHP @vestion Baye cts 4
Four data tie.
$
ita}
where a maP
Erom
Lf PHP.
attay —|
6) object
7) cesoure
8) Pon
example
ofdered
ociaies
its
is aN
tie that
» State
PHP
is
maP
a
kens -
atroy (Apple ',' Banana’ mepgo')
of for each loo?
as $value )
be executed 5
hoy
ts PCocess
data tie
biPe cas ting &
convertiag g
to__ another
p
oF
one’
— This ts done
using _tiPecas ting operators,
= Snteé + Svarigble
(new -tife) $ valve;
[
IL
he“Banana, "Pange
[eee fruits =] pppie
en =_imPlade (" Ps Eruits )
Leche ting mi
—aT i
4 How to acd valve. +o_end of an Gtfa+- 1
74) to veral is Ib £0.
7 todd valves te end of attay- Some of ther
“serene 2 Noted below =
_ eS bunks L" peele", " Banana "J i # Iv. 1g cphay fish,
Tartqy - Push? serviks , *ropgo) i # I osing C)——y
| $ftuits E] = " ofapge * 5 ]
1
zlwhat f vse Of tisk Func tigi,
J) = ler ) Function is used assign values
From, on affay to muitiPie vaprables
|
I = Bent a coovipient war to +rack_ and
| assign afray elements.
[—eu. sipo = Lt gohin “1,125, " Engineer)
stC$name_, sage . Sob ) = Sino 'jExPlatr Use of break and onhpu batemens |
|ibreqk +
[this $s an Keyword which is vsed 2 to deter.
control _» to Neét Staten,
! mingie and fan scer
tnside cr looP or sutkh Case —
itehen encounters
| Statement
Sint Cp. %
I< a. PpP
for (faze 4 4d "4
ge
fecha “end"4
| 4?
7if
2 | ExP lain ZO dexed artay and associa ti
Ai with example
PIR Indexed array -
pri The Byelue civic accessed ng indexes
—these tfe of arrays can be used +t
toCe ony tipe 66F €lemen:s
- By defaut Index Starks at zero.
I= Tes Won, OF ofegtin associative atfays
ag
yp $ colot = atlas (' Red’. ‘Bive' * pur pie')
2? Scolors Lo] = “Red”,
6 colors i\ =“ Bive":
Scolors fz] = " Pupie”:
Cx
@ phe
$ colors = attay ("yellow ” ."Rive", "Red", “white }
echo Scolors Li) Fyn” |
Cche S$ colas fo} "vn";
echo $ cogs [aj o"5Associative atray
[= These arfars are used to store Key
value Patrs _
= Associative affay have bring as key
-and behave ike two column table try
& leotumn fs key 4 which is used +0
| the value
I wart ae feate as
fy (2 =
| : "Engl MeD%9 Bo) i
Io)? $studept £" rrath 72 295 5
$ studenti ["scleace "7 = 85 5
Two
ORES.
| <2 php
16 Student = afray (aMiath” 2) 45, "sci
“Bpgiigh " 22.98);
echo “rath? 2 $ctudent C" math), "s\n" i
hecho “ccience”. g student [ "science Tens
echo " English”. dstudent [eng lish "7, tn"
| &y
peccribe 1pta of ff else control
Gicters Gratement with exam Pile.
<7 Te else conto} tatement+ Ps uced
Lito checte whether con dttron *s_ trve or
falce,
|- TE condition evaluites to true then
Lblock of code associated with tf gers
ecu te A.= ition fs False ¥ io
Jated pith CEE gets exectted.
|= S71 tax =
| if Coon dition ) 5
True code block
ese §
False code bleck
&
— Exam le +
[<2 Phe*
| gars 304
J re Coa < 20) _
Echo "Variable valve 1s less than 20")
leise Ff
lecho “variable vale fs greater than 20")
| a
lwsite a PHP Program to _digPlay Po. Hom
\_to 10 in sequence vu ing — For_looP.
<2 PhP
eeire~
For Catz 15 gid2 5 gitt)
4
IC echo" $ iy< bri?’ 5
g
2)How to Store data
ec datan alt
using i ther atfay () Function or
Ghoct {) siniax in tndexed array
BE
{= 1) atfay ©)
_Follgwing is examPie OF Storing data ij
avfay esng arfay OQ Functien
L [<2 Phe
Servite = attarC' mange", "Ranana”, ' Apple” ) 5
2) 7
|-2) £)
[Konguing {1S cxomPe of Storing data in
LAttart us ing Short anbe
|| <9 Phe
Sewits = Ber LY 3
Secure strange"
& funts = "OPie”
22>
|
|= Ost ociative oftay.2ere: aldo ft tife +
| suce data in an arta
lew <2 PhP
| & Person = arlay ¢
[ “pame "27 "John" "age =) 28
| WC 22 “Lag vegas” Ji
“use” i
0
| &Pers on L*-ontry "JD
| pripne—p-4Percon
leche Print c ($fers om )
Pos -USC x
Si 288 “C
432 Setver comPatininny — I+ supports varius
Wwe server UKE Pathe i Weiny and
se (Os oF I)
4) High Performance — Php scripts execute
Faster that many other lang veg 5
5) Scalability = Php yeed by lapge sae
Mebsites Nike facebook enc werd Press,
demons sretiay lig dbitity to hand® high
Hare ie
16) Platform InckePendence ~ PhP song on
multiple #) - Including eoMdow maces | |ny
PY Database tote gration = PhP seamless)
ote grates ith “muitiPile databas like
Masel, MongopB-
2 Frame wotle _Pveii lity = PoPular frameuert
Nak lafavel Code lg plier Make ckeve tof omen!
Fas ter,