TEST 1 FOR PHP QUESTIONS AND
CORRECT ANSWERS
AA2webA2applicationA2isA2aA2typeA2ofA2-A2Ans--client/serverA2application
WhenA2theA2webA2serverA2receivesA2anA2HTTPA2requestA2forA2aA2PHPA2page,A2theA2webA2
serverA2callsA2theA2-A2Ans--webA2browser
WhichA2ofA2theA2followingA2softwareA2componentsA2generatesA2theA2HTMLA2thatA2isA2retur
nedA2inA2anA2HTTPA2response?A2-A2Ans--Chrome
TheA2HTTPA2responseA2forA2aA2dynamicA2webA2pageA2isA2passedA2-A2Ans--
fromA2theA2webA2serverA2toA2theA2browser
WhichA2ofA2theA2followingA2isA2NOTA2trueA2aboutA2MariaDB?A2-A2Ans--
itA2isA2beingA2maintainedA2byA2manyA2ofA2theA2originalA2developersA2ofA2MySQL.
ToA2deployA2aA2PHPA2applicationA2onA2yourA2ownA2computer,A2youA2copyA2theA2applicatio
nA2rootA2directoryA2toA2-A2Ans--theA2htdocsA2directoryA2ofA2theA2ApacheA2server
WhichA2HTMLA2tagA2orA2elementA2isA2usedA2toA2loadA2anA2externalA2stylesheet?A2-A2Ans--
link
ToA2runA2aA2PHPA2applicationA2thatA2hasA2beenA2deployedA2onA2yourA2ownA2computer,A2y
ouA2canA2enterA2aA2URLA2inA2theA2addressA2barA2ofA2yourA2browserA2thatA2-A2Ans--
usesA2localhostA2asA2theA2domainA2name
InA2HTML,A2parametersA2areA2calledA2-A2Ans--attributes
TheA2firstA2partA2ofA2aA2URLA2isA2calledA2theA2-A2Ans--protocol
WhichA2ofA2theA2followingA2isA2NOTA2partA2ofA2anA2HTTPA2URL:A2-A2Ans--node
WhenA2HTMLA2wasA2firstA2developed,A2WebA2pagesA2wereA2typicallyA2-A2Ans--static
IfA2aA2URLA2specifiesA2aA2directoryA2thatA2doesn'tA2containA2aA2defaultA2page,A2ApacheA2di
splaysA2-A2Ans--aA2listA2ofA2allA2ofA2theA2directoriesA2inA2thatA2directory
WhichA2ofA2theA2followingA2isA2notA2aA2databaseA2serverA2thatA2canA2beA2usedA2forA2dyna
micA2WebA2pages?A2-A2Ans--Python
ToA2viewA2theA2sourceA2codeA2forA2aA2webA2pageA2inA2aA2webA2browser,A2youA2canA2displ
ayA2theA2ViewA2SourceA2commandA2byA2-A2Ans--right-clickingA2onA2theA2page
,ToA2makeA2itA2easierA2toA2enterA2namesA2intoA2yourA2code,A2NetBeansA2providesA2aA2feat
ureA2knownA2asA2-A2Ans--auto-completion
URLA2standsA2forA2-A2Ans--UniformA2ResourceA2Locator
AA2requestA2andA2responseA2forA2aA2fileA2areA2madeA2byA2-A2Ans--
aA2clientA2andA2aA2server
WhatA2typeA2ofA2aA2requestA2doesA2aA2WebA2browserA2typicallyA2sendA2toA2aA2server?A2-
A2Ans--HTTP
WhatA2extensionA2ofA2aA2filenameA2isA2typicallyA2associatedA2withA2aA2staticA2WebA2page?
A2-A2Ans--.htm
WhichA2ofA2theA2followingA2canA2beA2usedA2toA2styleA2aA2labelA2inA2anA2idA2namedA2data?
A2-A2Ans--#dataA2label
WhichA2ofA2theA2followingA2isA2softwareA2thatA2isA2aA2WebA2server?A2-A2Ans--Apache
WhichA2ofA2theA2followingA2canA2beA2displayedA2ifA2youA2omitA2theA2filenameA2ofA2aA2URL?
A2-A2Ans--allA2ofA2these
AA2PHPA2variableA2nameA2-A2Ans--isA2case-sensitive
TheA2orderA2ofA2precedenceA2forA2arithmeticA2expressionsA2causesA2-A2Ans--
incrementA2operationsA2toA2beA2doneA2first
ToA2roundA2andA2formatA2theA2valueA2ofA2aA2variableA2namedA2$numberA2toA23A2decimalA2
placesA2andA2storeA2itA2inA2aA2variableA2namedA2$number_formatted,A2youA2codeA2-
A2Ans--$number_formattedA2=A2number_format($number,A23);
AfterA2theA2codeA2thatA2followsA2isA2executed,A2whatA2willA2theA2valueA2ofA2$units_per_sto
reA2be?
$unitsA2=A230;
$storesA2=A24;
$units_per_storeA2=A2intdiv($units,A2$stores);A2-A2Ans--7
AfterA2theA2codeA2thatA2followsA2isA2executed,A2whatA2willA2theA2valueA2ofA2$units_per_sto
reA2be?
$unitsA2=A230;
$storesA2=A24;
$units_per_storeA2=A2$unitsA2%A2$stores;A2-A2Ans--2
AfterA2theA2ifA2statementA2thatA2followsA2isA2executed,A2whatA2willA2theA2valueA2ofA2$disco
unt_amountA2be?
$discount_amount;
, $order_totalA2=A2200;
ifA2($order_totalA2>A2200)A2{
A2$discount_amountA2=A2$order_totalA2*A2.3;
}A2elseA2ifA2($order_totalA2>A2100)A2{
A2$discount_amountA2=A2$order_totalA2*A2.2;
}A2elseA2{
A2$discount_amountA2=A2$order_totalA2*A2.1;
}A2-A2Ans--40
IfA2$total_monthsA2hasA2aA2valueA2ofA213,A2whatA2doesA2$messageA2containA2afterA2thisA2i
fA2statementA2isA2executed?A2
$yearsA2=A2$total_monthsA2/A212;
$yearsA2=A2number_format($years);
$monthsA2=A2$total_monthsA2%A212;
ifA2(A2$yearsA2==A20A2)A2{
A2$messageA2=A2$monthsA2.A2"A2months";
}A2elseA2ifA2(A2$monthsA2==A20A2)A2{
A2$messageA2=A2$yearsA2.A2"A2years";
}A2elseA2{
A2$messageA2=A2$yearsA2.A2"A2years,A2andA2"A2.A2$monthsA2.A2"A2months";
}A2-A2Ans--1A2years,A2andA21A2months
HowA2manyA2timesA2willA2theA2whileA2loopA2thatA2followsA2beA2executed?
$monthsA2=A25;
$iA2=A21;
whileA2($iA2>A2$months)A2{
A2$futureValueA2=A2$futureValueA2*A2(1A2+A2$monthlyInterestRate);
A2$iA2=A2$i+1;
}A2-A2Ans--0
WhatA2willA2$future_valueA2containA2afterA2theA2forA2loopA2thatA2followsA2hasA2beenA2exec
utedA2oneA2time?
$yearsA2=A210;
$annual_rateA2=A210;
$future_valueA2=A21000;
$annual_rateA2=A2$annual_rateA2/A2100;
forA2(A2$iA2=A21;A2$iA2<=A2$years;A2$i++A2)A2{
A2$future_valueA2=A2$future_valueA2*A2(1A2+A2$annual_rate);A2-A2Ans--1100
InA2theA2codeA2thatA2follows,A2ifA2$error_messageA2isn'tA2empty
A2ifA2($error_messageA2!=A2'')A2{
A2include('index.php');
A2exit();A2
A2}A2-A2Ans--
controlA2isA2passedA2toA2aA2pageA2namedA2index.phpA2that'sA2inA2theA2currentA2directory
CORRECT ANSWERS
AA2webA2applicationA2isA2aA2typeA2ofA2-A2Ans--client/serverA2application
WhenA2theA2webA2serverA2receivesA2anA2HTTPA2requestA2forA2aA2PHPA2page,A2theA2webA2
serverA2callsA2theA2-A2Ans--webA2browser
WhichA2ofA2theA2followingA2softwareA2componentsA2generatesA2theA2HTMLA2thatA2isA2retur
nedA2inA2anA2HTTPA2response?A2-A2Ans--Chrome
TheA2HTTPA2responseA2forA2aA2dynamicA2webA2pageA2isA2passedA2-A2Ans--
fromA2theA2webA2serverA2toA2theA2browser
WhichA2ofA2theA2followingA2isA2NOTA2trueA2aboutA2MariaDB?A2-A2Ans--
itA2isA2beingA2maintainedA2byA2manyA2ofA2theA2originalA2developersA2ofA2MySQL.
ToA2deployA2aA2PHPA2applicationA2onA2yourA2ownA2computer,A2youA2copyA2theA2applicatio
nA2rootA2directoryA2toA2-A2Ans--theA2htdocsA2directoryA2ofA2theA2ApacheA2server
WhichA2HTMLA2tagA2orA2elementA2isA2usedA2toA2loadA2anA2externalA2stylesheet?A2-A2Ans--
link
ToA2runA2aA2PHPA2applicationA2thatA2hasA2beenA2deployedA2onA2yourA2ownA2computer,A2y
ouA2canA2enterA2aA2URLA2inA2theA2addressA2barA2ofA2yourA2browserA2thatA2-A2Ans--
usesA2localhostA2asA2theA2domainA2name
InA2HTML,A2parametersA2areA2calledA2-A2Ans--attributes
TheA2firstA2partA2ofA2aA2URLA2isA2calledA2theA2-A2Ans--protocol
WhichA2ofA2theA2followingA2isA2NOTA2partA2ofA2anA2HTTPA2URL:A2-A2Ans--node
WhenA2HTMLA2wasA2firstA2developed,A2WebA2pagesA2wereA2typicallyA2-A2Ans--static
IfA2aA2URLA2specifiesA2aA2directoryA2thatA2doesn'tA2containA2aA2defaultA2page,A2ApacheA2di
splaysA2-A2Ans--aA2listA2ofA2allA2ofA2theA2directoriesA2inA2thatA2directory
WhichA2ofA2theA2followingA2isA2notA2aA2databaseA2serverA2thatA2canA2beA2usedA2forA2dyna
micA2WebA2pages?A2-A2Ans--Python
ToA2viewA2theA2sourceA2codeA2forA2aA2webA2pageA2inA2aA2webA2browser,A2youA2canA2displ
ayA2theA2ViewA2SourceA2commandA2byA2-A2Ans--right-clickingA2onA2theA2page
,ToA2makeA2itA2easierA2toA2enterA2namesA2intoA2yourA2code,A2NetBeansA2providesA2aA2feat
ureA2knownA2asA2-A2Ans--auto-completion
URLA2standsA2forA2-A2Ans--UniformA2ResourceA2Locator
AA2requestA2andA2responseA2forA2aA2fileA2areA2madeA2byA2-A2Ans--
aA2clientA2andA2aA2server
WhatA2typeA2ofA2aA2requestA2doesA2aA2WebA2browserA2typicallyA2sendA2toA2aA2server?A2-
A2Ans--HTTP
WhatA2extensionA2ofA2aA2filenameA2isA2typicallyA2associatedA2withA2aA2staticA2WebA2page?
A2-A2Ans--.htm
WhichA2ofA2theA2followingA2canA2beA2usedA2toA2styleA2aA2labelA2inA2anA2idA2namedA2data?
A2-A2Ans--#dataA2label
WhichA2ofA2theA2followingA2isA2softwareA2thatA2isA2aA2WebA2server?A2-A2Ans--Apache
WhichA2ofA2theA2followingA2canA2beA2displayedA2ifA2youA2omitA2theA2filenameA2ofA2aA2URL?
A2-A2Ans--allA2ofA2these
AA2PHPA2variableA2nameA2-A2Ans--isA2case-sensitive
TheA2orderA2ofA2precedenceA2forA2arithmeticA2expressionsA2causesA2-A2Ans--
incrementA2operationsA2toA2beA2doneA2first
ToA2roundA2andA2formatA2theA2valueA2ofA2aA2variableA2namedA2$numberA2toA23A2decimalA2
placesA2andA2storeA2itA2inA2aA2variableA2namedA2$number_formatted,A2youA2codeA2-
A2Ans--$number_formattedA2=A2number_format($number,A23);
AfterA2theA2codeA2thatA2followsA2isA2executed,A2whatA2willA2theA2valueA2ofA2$units_per_sto
reA2be?
$unitsA2=A230;
$storesA2=A24;
$units_per_storeA2=A2intdiv($units,A2$stores);A2-A2Ans--7
AfterA2theA2codeA2thatA2followsA2isA2executed,A2whatA2willA2theA2valueA2ofA2$units_per_sto
reA2be?
$unitsA2=A230;
$storesA2=A24;
$units_per_storeA2=A2$unitsA2%A2$stores;A2-A2Ans--2
AfterA2theA2ifA2statementA2thatA2followsA2isA2executed,A2whatA2willA2theA2valueA2ofA2$disco
unt_amountA2be?
$discount_amount;
, $order_totalA2=A2200;
ifA2($order_totalA2>A2200)A2{
A2$discount_amountA2=A2$order_totalA2*A2.3;
}A2elseA2ifA2($order_totalA2>A2100)A2{
A2$discount_amountA2=A2$order_totalA2*A2.2;
}A2elseA2{
A2$discount_amountA2=A2$order_totalA2*A2.1;
}A2-A2Ans--40
IfA2$total_monthsA2hasA2aA2valueA2ofA213,A2whatA2doesA2$messageA2containA2afterA2thisA2i
fA2statementA2isA2executed?A2
$yearsA2=A2$total_monthsA2/A212;
$yearsA2=A2number_format($years);
$monthsA2=A2$total_monthsA2%A212;
ifA2(A2$yearsA2==A20A2)A2{
A2$messageA2=A2$monthsA2.A2"A2months";
}A2elseA2ifA2(A2$monthsA2==A20A2)A2{
A2$messageA2=A2$yearsA2.A2"A2years";
}A2elseA2{
A2$messageA2=A2$yearsA2.A2"A2years,A2andA2"A2.A2$monthsA2.A2"A2months";
}A2-A2Ans--1A2years,A2andA21A2months
HowA2manyA2timesA2willA2theA2whileA2loopA2thatA2followsA2beA2executed?
$monthsA2=A25;
$iA2=A21;
whileA2($iA2>A2$months)A2{
A2$futureValueA2=A2$futureValueA2*A2(1A2+A2$monthlyInterestRate);
A2$iA2=A2$i+1;
}A2-A2Ans--0
WhatA2willA2$future_valueA2containA2afterA2theA2forA2loopA2thatA2followsA2hasA2beenA2exec
utedA2oneA2time?
$yearsA2=A210;
$annual_rateA2=A210;
$future_valueA2=A21000;
$annual_rateA2=A2$annual_rateA2/A2100;
forA2(A2$iA2=A21;A2$iA2<=A2$years;A2$i++A2)A2{
A2$future_valueA2=A2$future_valueA2*A2(1A2+A2$annual_rate);A2-A2Ans--1100
InA2theA2codeA2thatA2follows,A2ifA2$error_messageA2isn'tA2empty
A2ifA2($error_messageA2!=A2'')A2{
A2include('index.php');
A2exit();A2
A2}A2-A2Ans--
controlA2isA2passedA2toA2aA2pageA2namedA2index.phpA2that'sA2inA2theA2currentA2directory