0% found this document useful (0 votes)
3K views

Advanced PHP - 100 PHP Interview Questions and Answers PDF

Uploaded by

naresh50787
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views

Advanced PHP - 100 PHP Interview Questions and Answers PDF

Uploaded by

naresh50787
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

1/28/2015

AdvancedPHP:100PHPInterviewQuestionsandAnswers
0

More NextBlog

CreateBlog SignIn

AdvancedPHP
SchoolforAdvancedPHPProgrammingTechniques.
Home

JavaScript

PHPBasics

phpoops

MySQL

Sunday,October9,2011

BlogArchive

100PHPInterviewQuestionsandAnswers

2011(4)

100PHPinterviewquestionsandanswersarebelow.
Questions:1 WhoisthefatherofPHP?
Answers:1
RasmusLerdorfisknownasthefatherofPHP.
Questions:2 Whatisthedifferencebetween$nameand$$name?
Answers:2
$nameisvariablewhereas$$nameisreferencevariablelike$name=soniaand
$$name=singhso$soniavalueissingh.
Questions:3 Howcanwesubmitaformwithoutasubmitbutton?
Answer:3
Javascriptsubmit()functionisusedforsubmitformwithoutsubmitbuttononclick
calldocument.formname.submit()
Questions:4 InhowmanywayswecanretrievethedataintheresultsetofMySQLusing
PHP?
Answer:4
Wecandoitby4Ways1.mysql_fetch_row.,2.mysql_fetch_array,3.
mysql_fetch_object4.mysql_fetch_assoc
Questions:5 Whatisthedifferencebetweenmysql_fetch_objectandmysql_fetch_array?
Answers:5
mysql_fetch_object()issimilartomysql_fetch_array(),withonedifferencean
objectisreturned,insteadofanarray.Indirectly,thatmeansthatyoucanonlyaccess
thedatabythefieldnames,andnotbytheiroffsets(numbersareillegalproperty
names).
Questions:6 WhatarethedifferencesbetweenGetandpostmethods.
Answers:6
TherearesomedefferencebetweenGETandPOSTmethod1.GETMethodhave
somelimitlikeonly2KbdataabletosendforrequestButinPOSTmethodunlimited
datacanwesend2.whenweuseGETmethodrequesteddatashowinurlbutNotin
POSTmethodsoPOSTmethodisgoodforsendsensetiverequest
Questions:7 Howcanweextractstring"pcds.co.in"fromastring"http://[email protected]
usingregularexpressionofPHP?
Answers:7
preg_match("/^http:\/\/.+@(.+)$/","http://[email protected]",$matches)echo
$matches[1]
Questions:8 HowcanwecreateadatabaseusingPHPandMySQL?
Answers:8
WecancreateMySQLdatabasewiththeuseofmysql_create_db("DatabaseName")
Questions:9 Whatarethedifferencesbetweenrequireandinclude?
Answers:9
BothincludeandrequireusedtoincludeafilebutwhenincludedfilenotfoundInclude
sendWarningwhereasRequiresendFatalError.
Questions:10 Canweuseinclude("xyz.PHP")twotimesinaPHPpage"index.PHP"?
Answers:10 Yeswecanuseinclude("xyz.php")morethanonetimeinanypage.butitcreatea
probwhenxyz.phpfilecontainsomefuntionsdeclarationthenerrorwillcomefor
alreadydeclaredfunctioninthisfileelsenotaproblikeifyouwanttoshowsame
contenttwotimeinpagethenmustincudeittwotimenotaprob
Questions:11 Whatarethedifferenttables(Engine)presentinMySQL,whichoneisdefault?
Answers:11 Followingtables(StorageEngine)wecancreate1.MyISAM(Thedefaultstorage
engineINMYSQLEachMyISAMtableisstoredondiskinthreefiles.Thefileshave
namesthatbeginwiththetablenameandhaveanextensiontoindicatethefiletype.
An.frmfilestoresthetableformat.Thedatafilehasan.MYD(MYData)extension.
Theindexfilehasan.MYI(MYIndex)extension.)2.InnoDB(InnoDBisa
transactionsafe(ACIDcompliant)storageengineforMySQLthathascommit,
rollback,andcrashrecoverycapabilitiestoprotectuserdata.)3.Merge4.Heap
(MEMORY)(TheMEMORYstorageenginecreatestableswithcontentsthatare
storedinmemory.Formerly,thesewereknownasHEAPtables.MEMORYisthe
preferredterm,althoughHEAPremainssupportedforbackwardcompatibility.)5.
BDB(BerkeleyDB)(SleepycatSoftwarehasprovidedMySQLwiththeBerkeleyDB
transactionalstorageengine.ThisstorageenginetypicallyiscalledBDBforshort.
BDBtablesmayhaveagreaterchanceofsurvivingcrashesandarealsocapableof
COMMITandROLLBACKoperationsontransactions)6.EXAMPLE7.
FEDERATED(Itisastorageenginethataccessesdataintablesofremote
databasesratherthaninlocaltables.)8.ARCHIVE(TheARCHIVEstorageengine
isusedforstoringlargeamountsofdatawithoutindexesinaverysmallfootprint.)9.
CSV(TheCSVstorageenginestoresdataintextfilesusingcommaseparated

http://school4php.blogspot.in/2011/10/100phpinterview.html

October(4)
JavaScriptInterviewQuestionsand
Answers
HistoryofPHPandrelatedprojects
AdvancedPHP:phpoops
100PHPInterviewQuestionsand
Answers

Followers

Jointhissite
withGoogleFriendConnect

Members(13)

Alreadyamember?Signin

FollowbyEmail

Emailaddress...

Submit

AboutMe

NagaRajuDanne
Follow

47

Viewmycompleteprofile

1/10

1/28/2015

AdvancedPHP:100PHPInterviewQuestionsandAnswers

Questions:12
Answers:12

Questions:13
Answers:13
Questions:14
Answers:14
Questions:15
Answers:15
Questions:16
Answers:16
Questions:17
Answers:17

Questions:18
Answers:18
Questions:19

valuesformat.)10.BLACKHOLE(TheBLACKHOLEstorageengineactsasa"black
hole"thatacceptsdatabutthrowsitawayanddoesnotstoreit.Retrievalsalways
returnanemptyresult)
Whatisuseofheader()functioninphp?
Theheader()functionsendsarawHTTPheadertoaclient.Wecanuseherder()
functionforredirectionofpages.Itisimportanttonoticethatheader()mustbecalled
beforeanyactualoutputisseen..
HowcanIexecuteaPHPscriptusingcommandline?
JustrunthePHPCLI(CommandLineInterface)programandprovidethePHPscript
filenameasthecommandlineargument.
SupposeyourZendenginesupportsthemode<??>Thenhowcanuconfigure
yourPHPZendenginetosupport<?PHP?>mode?
Inphp.inifile:setshort_open_tag=ontomakePHPsupport
Shoppingcartonlinevalidationi.e.howcanweconfigurePaypal,etc.?
NothingmorewehavetodoonlyredirecttothepayPalurlaftersubmitallinformation
neededbypaypallikeamount,adresssetc.
Whatismeantbynl2br()?
InsertsHTMLlinebreaks(<BR/>)beforeallnewlinesinastring.
Whatishtaccess?WhydoweusethisandWhere?
.htaccessfilesareconfigurationfilesofApacheServerwhichprovideawaytomake
configurationchangesonaperdirectorybasis.Afile,containingoneormore
configurationdirectives,isplacedinaparticulardocumentdirectory,andthe
directivesapplytothatdirectory,andallsubdirectoriesthereof.
HowwegetIPaddressofclient,previousreferencepageetc?
Byusing$_SERVER['REMOTE_ADDR'],$_SERVER['HTTP_REFERER']etc.
Whatarethereasonsforselectinglamp(Linux,apache,MySQL,PHP)insteadof
combinationofothersoftwareprograms,serversandoperatingsystems?

Answers:19

Allofthoseareopensourceresource.SecurityofLinuxisveryverymorethan
windows.ApacheisabetterserverthatIISbothinfunctionalityandsecurity.MySQL
isworldmostpopularopensourcedatabase.PHPismorefasterthatasporanyother
scriptinglanguage.
Questions:20 HowcanweencryptanddecryptadatapresentinaMySQLtableusingMySQL?
Answers:20 AES_ENCRYPT()andAES_DECRYPT()
Questions:21 HowcanweencrypttheusernameandpasswordusingPHP?
Answers:21 Thefunctionsinthissectionperformencryptionanddecryption,andcompressionand
uncompression:
encryption

decryption

AES_ENCRYT()

AES_DECRYPT()

ENCODE()

DECODE()

DES_ENCRYPT()

DES_DECRYPT()

ENCRYPT()

Notavailable

MD5()

Notavailable

OLD_PASSWORD() Notavailable
PASSWORD()

Notavailable

SHA()orSHA1()

Notavailable

Notavailable

UNCOMPRESSED_LENGTH()

Questions:22 Whatarethefeaturesandadvantagesofobjectorientedprogramming?
Answers:22 OneofthemainadvantagesofOOprogrammingisitseaseofmodificationobjects
caneasilybemodifiedandaddedtoasystemtherebyreducingmaintenancecosts.
OOprogrammingisalsoconsideredtobebetteratmodelingtherealworldthanis
proceduralprogramming.Itallowsformorecomplicatedandflexibleinteractions.OO
systemsarealsoeasierfornontechnicalpersonneltounderstandandeasierforthem
toparticipateinthemaintenanceandenhancementofasystembecauseitappealsto
naturalhumancognitionpatterns.Forsomesystems,anOOapproachcanspeed
developmenttimesincemanyobjectsarestandardacrosssystemsandcanbe
reused.Componentsthatmanagedates,shipping,shoppingcarts,etc.canbe
purchasedandeasilymodifiedforaspecificsystem
Questions:23 Whatarethedifferencesbetweenprocedureorientedlanguagesandobject
orientedlanguages?
Answers:23 Therearelotofdifferencebetweenprocedurelanguageandobjectorientedlikebelow
1>Procedurelanguageeasyfornewdeveloperbutcomplextounderstandwhole
softwareascomparetoobjectorientedmodel2>InProcedurelanguageitisdifficultto
usedesignpatternmvc,SingletonpatternetcbutinOOPyouweabletodevelop
designpattern3>INOOPlanguageweabletoreeusecodelikeInheritance
,polymorphismetcbutthistypeofthingnotavailableinprocedurelanguageonthat
ourFondauseCOPYandPASTE.
Questions:24 Whatistheuseoffriendfunction?
Answers:24 Sometimesafunctionisbestsharedamonganumberofdifferentclasses.Such
functionscanbedeclaredeitherasmemberfunctionsofoneclassorasglobal
functions.Ineithercasetheycanbesettobefriendsofotherclasses,byusinga
friendspecifierintheclassthatisadmittingthem.Suchfunctionscanuseall
attributesoftheclasswhichnamesthemasafriend,asiftheywerethemselves
membersofthatclass.Afrienddeclarationisessentiallyaprototypeforamember

http://school4php.blogspot.in/2011/10/100phpinterview.html

2/10

1/28/2015

AdvancedPHP:100PHPInterviewQuestionsandAnswers

Questions:25
Answer:25

Questions:26
Answer:26

Questions:27
Answers:27

Questions:28
Answer:28

Questions:29
Answer:29
Questions:30
Answer:30

function,butinsteadofrequiringanimplementationwiththenameofthatclass
attachedbythedoublecolonsyntax,aglobalfunctionormemberfunctionofanother
classprovidesthematch.
Whatarethedifferencesbetweenpublic,private,protected,static,transient,
finalandvolatile?
Public:Publicdeclareditemscanbeaccessedeverywhere.Protected:Protected
limitsaccesstoinheritedandparentclasses(andtotheclassthatdefinestheitem).
Private:Privatelimitsvisibilityonlytotheclassthatdefinestheitem.Static:Astatic
variableexistsonlyinalocalfunctionscope,butitdoesnotloseitsvaluewhen
programexecutionleavesthisscope.Final:Finalkeywordpreventschildclasses
fromoverridingamethodbyprefixingthedefinitionwithfinal.Iftheclassitselfis
beingdefinedfinalthenitcannotbeextended.transient:Atransientvariableisa
variablethatmaynotbeserialized.volatile:avariablethatmightbeconcurrently
modifiedbymultiplethreadsshouldbedeclaredvolatile.Variablesdeclaredtobe
volatilewillnotbeoptimizedbythecompilerbecausetheirvaluecanchangeatany
time.
WhatarethedifferenttypesoferrorsinPHP?
Threearethreetypesoferrors:1.Notices:Thesearetrivial,noncriticalerrorsthat
PHPencounterswhileexecutingascriptforexample,accessingavariablethat
hasnotyetbeendefined.Bydefault,sucherrorsarenotdisplayedtotheuseratall
although,asyouwillsee,youcanchangethisdefaultbehavior.2.Warnings:These
aremoreseriouserrorsforexample,attemptingtoinclude()afilewhichdoesnot
exist.Bydefault,theseerrorsaredisplayedtotheuser,buttheydonotresultinscript
termination.3.Fatalerrors:Thesearecriticalerrorsforexample,instantiatingan
objectofanonexistentclass,orcallinganonexistentfunction.Theseerrorscause
theimmediateterminationofthescript,andPHP'sdefaultbehavioristodisplaythem
totheuserwhentheytakeplace.
Whatisthefunctionalityofthefunctionstrstrandstristr?
strstrReturnspartofstringfromthefirstoccurrenceofneedle(substringthatwe
findingout)totheendofstring.$email='[email protected]'$domain=
strstr($email,'@')echo$domain//[email protected]@istheneedlestristris
caseinsensitivemeansablenotabletodiffrenciatebetweenaandA
WhatarethedifferencesbetweenPHP3andPHP4andPHP5?
Therearelotofdifferenceamongthesethreeversionofphp1>Php3isoldestversion
afterthatphp4cameandcurrentversionisphp5(php5.3)wherephp6havetocome
2>Differencemeanoldestversionhavelessfunctionalityascomparetonewonelike
php5haveallOOPsconceptnowwhereasphp3waspureprocedurallanguage
constructivelikeCInPHP51.Implementationofexceptionsandexceptionhandling
2.Typehintingwhichallowsyoutoforcethetypeofaspecificargument3.
Overloadingofmethodsthroughthe__callfunction4.Fullconstructorsand
destructorsetcthrougha__constuctorand__destructorfunction5.__autoload
functionfordynamicallyincludingcertainincludefilesdependingontheclassyouare
tryingtocreate.6Finality:cannowusethefinalkeywordtoindicatethatamethod
cannotbeoverriddenbyachild.Youcanalsodeclareanentireclassasfinalwhich
preventsitfromhavinganychildrenatall.7Interfaces&AbstractClasses8Passed
byReference:9An__clonemethodifyoureallywanttoduplicateanobject
HowcanweconvertasppagestoPHPpages?
therearelotsoftoolsavailableforasptoPHPconversion.youcansearchGooglefor
that.thebestoneisavailableathttp://asp2php.naken.cc./
Whatisthefunctionalityofthefunctionhtmlentities?
ConvertallapplicablecharacterstoHTMLentitiesThisfunctionisidenticalto
htmlspecialchars()inallways,exceptwithhtmlentities(),allcharacterswhichhave
HTMLcharacterentityequivalentsaretranslatedintotheseentities.

Questions:31
Answer:31
Questions:32
Answer:32

Howcanwegetsecondofthecurrenttimeusingdatefunction?
$second=date("s")
HowcanweconvertthetimezonesusingPHP?
Byusingdate_default_timezone_getanddate_default_timezone_setfunctiononPHP
5.1.0<?php//Discoverwhat8aminTokyorelatestoontheEastCoastoftheUS//
SetthedefaulttimezonetoTokyotime:date_default_timezone_set('Asia/Tokyo')//
Nowgeneratethetimestampforthatparticulartimezone,onJan1st,2000$stamp=
mktime(8,0,0,1,1,2000)//NowsetthetimezonebacktoUS/Eastern
date_default_timezone_set('US/Eastern')//Outputthedateinastandardformat
(RFC1123),thiswillprint://Fri,31Dec199918:00:00ESTecho'<p>',
date(DATE_RFC1123,$stamp),'</p>'?>
Questions:33 Whatismeantbyurlencodeandurldocode?
Answer:33
URLencodereturnsastringinwhichallnonalphanumericcharactersexcept_.have
beenreplacedwithapercent(%)signfollowedbytwohexdigitsandspacesencoded
asplus(+)signs.ItisencodedthesamewaythattheposteddatafromaWWWform
isencoded,thatisthesamewayasinapplication/xwwwformurlencodedmedia
type.urldecodedecodesany%##encodinginthegivenstring.
Questions:34 Whatisthedifferencebetweenthefunctionsunlinkandunset?
Answer:34
unlink()deletesthegivenfilefromthefilesystem.unset()makesavariable
undefined.
Questions:35 Howcanweregisterthevariablesintoasession?
Answer:35
$_SESSION['name']="sonia"

http://school4php.blogspot.in/2011/10/100phpinterview.html

3/10

1/28/2015

AdvancedPHP:100PHPInterviewQuestionsandAnswers
Questions:36 Howcanwegettheproperties(size,type,width,height)ofanimageusingPHP
imagefunctions?
Answer:36

Questions:37
Answer:37
Questions:38
Answer:38
Questions:39
Answer:39
Questions:40
Answer:40

Questions:41
Answer:41

ToknowtheImagetypeuseexif_imagetype()functionToknowtheImagesizeuse
getimagesize()functionToknowtheimagewidthuseimagesx()functionToknow
theimageheightuseimagesy()functiont
HowcanwegetthebrowserpropertiesusingPHP?
Byusing$_SERVER['HTTP_USER_AGENT']variable.
WhatisthemaximumsizeofafilethatcanbeuploadedusingPHPandhow
canwechangethis?
Bydefaultthemaximumsizeis2MB.andwecanchangethefollowingsetupat
php.iniupload_max_filesize=2M
HowcanweincreasetheexecutiontimeofaPHPscript?
bychangingthefollowingsetupatphp.inimax_execution_time=30Maximum
executiontimeofeachscript,inseconds
HowcanwetakeabackupofaMySQLtableandhowcanwerestoreit.?
Tobackup:BACKUPTABLEtbl_name[,tbl_name]TO'/path/to/backup/directory'
RESTORETABLEtbl_name[,tbl_name]FROM
'/path/to/backup/directory'mysqldump:DumpingTableStructureandDataUtilityto
dumpadatabaseoracollectionofdatabaseforbackuporfortransferringthedatato
anotherSQLserver(notnecessarilyaMySQLserver).ThedumpwillcontainSQL
statementstocreatethetableand/orpopulatethetable.t,nocreateinfoDon't
writetablecreationinformation(theCREATETABLEstatement).d,nodataDon't
writeanyrowinformationforthetable.Thisisveryusefulifyoujustwanttogeta
dumpofthestructureforatable!
HowcanweoptimizeorincreasethespeedofaMySQLselectquery?
firstofallinsteadofusingselect*fromtable1,useselectcolumn1,
column2,column3..fromtable1
Lookfortheopportunitytointroduceindexinthetableyouarequerying.
uselimitkeywordifyouarelookingforanyspecificnumberofrowsfrom
theresultset.

Questions:42
Answer:42
Questions:43
Answer:43

Howmanywayscanwegetthevalueofcurrentsessionid?
session_id()returnsthesessionidforthecurrentsession.
Howcanwedestroythesession,howcanweunsetthevariableofasession?
session_unregisterUnregisteraglobalvariablefromthecurrentsession
session_unsetFreeallsessionvariables
Questions:44 Howcanwesetanddestroythecookienphp?
Answer:44
Byusingsetcookie(name,value,expire,path,domain)functionwecansetthe
cookieinphpSetthecookiesinpastfordestroy.likesetcookie("user","sonia",
time()+3600)forsetthecookiesetcookie("user","",time()3600)fordestroyordelete
thecookies
Questions:45 Howmanywayswecanpassthevariablethroughthenavigationbetweenthe
pages?
Answer:45
GET/QueryString
POST
Questions:46 Whatisthedifferencebetweenereg_replace()anderegi_replace()?
Answer:46
eregi_replace()functionisidenticaltoereg_replace()exceptthatthisignorescase
distinctionwhenmatchingalphabeticcharacters.eregi_replace()functionisidenticalto
ereg_replace()exceptthatthisignorescasedistinctionwhenmatchingalphabetic
characters.
Questions:47 Whatarethedifferentfunctionsinsortinganarray?
Answer:47
Sort(),arsort(),asort(),ksort(),natsort(),natcasesort(),rsort(),usort(),
array_multisort(),anduksort().
Questions:48 Howcanweknowthecount/numberofelementsofanarray?
Answer:48
2waysa)sizeof($urarray)Thisfunctionisanaliasofcount()b)count($urarray)
Questions:49 whatissession_set_save_handlerinPHP?
Answer:49
session_set_save_handler()setstheuserlevelsessionstoragefunctionswhichare
usedforstoringandretrievingdataassociatedwithasession.Thisismostuseful
whenastoragemethodotherthanthosesuppliedbyPHPsessionsispreferred.i.e.
Storingthesessiondatainalocaldatabase.
Questions:50 HowcanIknowthatavariableisanumberornotusingaJavaScript?
Answer:50
boolis_numeric(mixedvar)ReturnsTRUEifvarisanumberoranumericstring,
FALSEotherwise.oruseisNaN(mixedvar)TheisNaN()functionisusedtocheckifa
valueisnotanumber.
Questions:51 ListoutsometoolsthroughwhichwecandrawERdiagramsformysql.
Answer:51
CaseStudioSmartDraw
Questions:52 HowcanIretrievevaluesfromonedatabaseserverandstoretheminother
databaseserverusingPHP?
Answer:52
wecanalwaysfetchfromonedatabaseandrewritetoanother.hereisanicesolution
ofit.$db1=mysql_connect("host","user","pwd")mysql_select_db("db1",$db1)$res1
=mysql_query("query",$db1)$db2=mysql_connect("host","user","pwd")
mysql_select_db("db2",$db2)$res2=mysql_query("query",$db2)Atthispointyou
canonlyfetchrecordsfromyoupreviousResultSet,i.e$res1Butyoucannot
executenewqueryin$db1,evenifyousupplythelinkasbecausethelinkwas

http://school4php.blogspot.in/2011/10/100phpinterview.html

4/10

1/28/2015

AdvancedPHP:100PHPInterviewQuestionsandAnswers
overwrittenbythenewdb.soatthispointthefollowingscriptwillfail$res3=
mysql_query("query",$db1)//thiswillfailSohowtosolvethat?takealookbelow.
$db1=mysql_connect("host","user","pwd")mysql_select_db("db1",$db1)$res1=
mysql_query("query",$db1)$db2=mysql_connect("host","user","pwd",true)
mysql_select_db("db2",$db2)$res2=mysql_query("query",$db2)Somysql_connect
hasanotheroptionalbooleanparameterwhichindicateswhetheralinkwillbecreated
ornot.asweconnecttothe$db2withthisoptionalparametersetto'true',soboth
linkwillremainlive.nowthefollowingquerywillexecutesuccessfully.$res3=
mysql_query("query",$db1)
Questions:53
Answer:53
Questions:54
Answer:54

Questions:55
Answer:55

Questions:56
Answer:56

Questions:57
Answer:57

Questions:58
Answer:58

ListoutthepredefinedclassesinPHP?
DirectorystdClass__PHP_Incomplete_Classexceptionphp_user_filter
HowcanImakeascriptthatcanbebilanguage(supportsEnglish,German)?
Youcanmaintaintwoseparatelanguagefileforeachofthelanguage.allthelabels
areputtedinbothlanguagefilesasvariablesandassignthosevariablesinthePHP
source.onruntimechoosetherequiredlanguageoption.
Whatarethedifferencebetweenabstractclassandinterface?
Abstractclass:abstractclassesaretheclasswhereoneormoremethodsare
abstractbutnotnecessarilyallmethodhastobeabstract.Abstractmethodsarethe
methods,whicharedeclareinitsclassbutnotdefine.Thedefinitionofthose
methodsmustbeinitsextendingclass.Interface:Interfacesareonetypeofclass
whereallthemethodsareabstract.Thatmeansallthemethodsonlydeclaredbutnot
defined.Allthemethodsmustbedefinebyitsimplementedclass.
HowcanwesendmailusingJavaScript?
JavaScriptdoesnothaveanynetworkingcapabilitiesasitisdesignedtoworkon
clientsite.AsaresultwecannotsendmailsusingJavaScript.Butwecancallthe
clientsidemailprotocolmailtoviaJavaScripttopromptforanemailtosend.this
requirestheclienttoapproveit.
HowcanwerepairaMySQLtable?
ThesyntexforrepairingaMySQLtableisREPAIRTABLENAME,[TABLENAME,],
[Quick],[Extended]Thiscommandwillrepairthetablespecifiedifthequickisgiven
theMySQLwilldoarepairofonlytheindextreeiftheextendedisgivenitwillcreate
indexrowbyrow
Whataretheadvantagesofstoredprocedures,triggers,indexes?
AstoredprocedureisasetofSQLcommandsthatcanbecompiledandstoredinthe
server.Oncethishasbeendone,clientsdon'tneedtokeepreissuingtheentirequery
butcanrefertothestoredprocedure.Thisprovidesbetteroverallperformance
becausethequeryhastobeparsedonlyonce,andlessinformationneedstobesent
betweentheserverandtheclient.Youcanalsoraisetheconceptuallevelbyhaving
librariesoffunctionsintheserver.However,storedproceduresofcoursedoincrease
theloadonthedatabaseserversystem,asmoreoftheworkisdoneontheserver
sideandlessontheclient(application)side.Triggerswillalsobeimplemented.A
triggeriseffectivelyatypeofstoredprocedure,onethatisinvokedwhenaparticular
eventoccurs.Forexample,youcaninstallastoredprocedurethatistriggeredeach
timearecordisdeletedfromatransactiontableandthatstoredprocedure
automaticallydeletesthecorrespondingcustomerfromacustomertablewhenallhis
transactionsaredeleted.Indexesareusedtofindrowswithspecificcolumnvalues
quickly.Withoutanindex,MySQLmustbeginwiththefirstrowandthenreadthrough
theentiretabletofindtherelevantrows.Thelargerthetable,themorethiscosts.If
thetablehasanindexforthecolumnsinquestion,MySQLcanquicklydeterminethe
positiontoseektointhemiddleofthedatafilewithouthavingtolookatallthedata.
Ifatablehas1,000rows,thisisatleast100timesfasterthanreadingsequentially.If
youneedtoaccessmostoftherows,itisfastertoreadsequentially,becausethis
minimizesdiskseeks.

Questions:59 Whatisthemaximumlengthofatablename,databasename,andfieldnamein
MySQL?
Answer:59
Thefollowingtabledescribesthemaximumlengthforeachtypeofidentifier.
Identifier MaximumLength(bytes)
Database 64

Questions:60
Answer:60
Questions:61
Answer:61
Questions:62
Answer:62
Questions:63

Table

64

Column

64

Index

64

Alias

255

Therearesomerestrictionsonthecharactersthatmayappearinidentifiers:
HowmanyvaluescantheSETfunctionofMySQLtake?
MySQLsetcantakezeroormorevaluesbutatthemaximumitcantake64values
WhataretheothercommandstoknowthestructureoftableusingMySQL
commandsexceptexplaincommand?
describeTableName
Howmanytableswillcreatewhenwecreatetable,whatarethey?
The'.frm'filestoresthetabledefinition.Thedatafilehasa'.MYD'(MYData)
extension.Theindexfilehasa'.MYI'(MYIndex)extension,
Whatisthepurposeofthefollowingfileshavingextensions1).frm2).myd3)
.myi?Whatdothesefilescontain?

http://school4php.blogspot.in/2011/10/100phpinterview.html

5/10

1/28/2015

AdvancedPHP:100PHPInterviewQuestionsandAnswers
Answer:63

InMySql,thedefaulttabletypeisMyISAM.EachMyISAMtableisstoredondiskin
threefiles.Thefileshavenamesthatbeginwiththetablenameandhavean
extensiontoindicatethefiletype.The'.frm'filestoresthetabledefinition.Thedata
filehasa'.MYD'(MYData)extension.Theindexfilehasa'.MYI'(MYIndex)
extension,

Questions:64 WhatismaximumsizeofadatabaseinMySQL?
Answer:64
Iftheoperatingsystemorfilesystemplacesalimitonthenumberoffilesina
directory,MySQLisboundbythatconstraint.Theefficiencyoftheoperatingsystem
inhandlinglargenumbersoffilesinadirectorycanplaceapracticallimitonthe
numberoftablesinadatabase.Ifthetimerequiredtoopenafileinthedirectory
increasessignificantlyasthenumberoffilesincreases,databaseperformancecanbe
adverselyaffected.Theamountofavailablediskspacelimitsthenumberoftables.
MySQL3.22hada4GB(4gigabyte)limitontablesize.WiththeMyISAMstorage
engineinMySQL3.23,themaximumtablesizewasincreasedto65536terabytes
(25671bytes).Withthislargerallowedtablesize,themaximumeffectivetable
sizeforMySQLdatabasesisusuallydeterminedbyoperatingsystemconstraintson
filesizes,notbyMySQLinternallimits.TheInnoDBstorageenginemaintainsInnoDB
tableswithinatablespacethatcanbecreatedfromseveralfiles.Thisallowsatable
toexceedthemaximumindividualfilesize.Thetablespacecanincluderawdisk
partitions,whichallowsextremelylargetables.Themaximumtablespacesizeis
64TB.Thefollowingtablelistssomeexamplesofoperatingsystemfilesizelimits.
Thisisonlyaroughguideandisnotintendedtobedefinitive.Forthemostuptodate
information,besuretocheckthedocumentationspecifictoyouroperatingsystem.
OperatingSystemFilesizeLimitLinux2.2Intel32bit2GB(LFS:4GB)Linux2.4+
(usingext3filesystem)4TBSolaris9/1016TBNetWarew/NSSfilesystem8TB
Win32w/FAT/FAT322GB/4GBWin32w/NTFS2TB(possiblylarger)MacOSXw/
HFS+2TB
Questions:65 GivethesyntaxofGrantandRevokecommands?
Answer:65
Thegenericsyntaxforgrantisasfollowing>GRANT[rights]on[database/s]TO
[username@hostname]IDENTIFIEDBY[password]nowrightscanbea)All
privilegesb)combinationofcreate,drop,select,insert,updateanddeleteetc.Wecan
grantrightsonalldatabsebyusing*.*orsomespecificdatabasebydatabase.*ora
specifictablebydatabase.table_nameusername@hotsnamecanbeeither
username@localhost,username@hostnameandusername@%wherehostnameis
anyvalidhostnameand%representsanyname,the*.*anyconditionpasswordis
simplythepasswordofuserThegenericsyntaxforrevokeisasfollowing>REVOKE
[rights]on[database/s]FROM[username@hostname]nowrightscanbeasexplained
abovea)Allprivilegesb)combinationofcreate,drop,select,insert,updateanddelete
etc.username@hotsnamecanbeeitherusername@localhost,username@hostname
andusername@%wherehostnameisanyvalidhostnameand%representsany
name,the*.*anycondition
Questions:66 ExplainNormalizationconcept?
Answer:66
Thenormalizationprocessinvolvesgettingourdatatoconformtothreeprogressive
normalforms,andahigherlevelofnormalizationcannotbeachieveduntilthe
previouslevelshavebeenachieved(thereareactuallyfivenormalforms,butthelast
twoaremainlyacademicandwillnotbediscussed).FirstNormalFormTheFirst
NormalForm(or1NF)involvesremovalofredundantdatafromhorizontalrows.We
wanttoensurethatthereisnoduplicationofdatainagivenrow,andthatevery
columnstorestheleastamountofinformationpossible(makingthefield
atomic).SecondNormalFormWheretheFirstNormalFormdealswithredundancyof
dataacrossahorizontalrow,SecondNormalForm(or2NF)dealswithredundancyof
datainverticalcolumns.Asstatedearlier,thenormalformsareprogressive,soto
achieveSecondNormalForm,yourtablesmustalreadybeinFirstNormalForm.Third
NormalFormIhaveaconfessiontomakeIdonotoftenuseThirdNormalForm.In
ThirdNormalFormwearelookingfordatainourtablesthatisnotfullydependanton
theprimarykey,butdependantonanothervalueinthetable
Questions:67 HowcanwefindthenumberofrowsinatableusingMySQL?
Answer:67
Usethisformysql>SELECTCOUNT(*)FROMtable_name
Questions:68 HowcanwefindthenumberofrowsinaresultsetusingPHP?
Answer:68
$result=mysql_query($sql,$db_link)$num_rows=mysql_num_rows($result)echo
"$num_rowsrowsfound"
Questions:69 HowmanywayswecanwefindthecurrentdateusingMySQL?
Answer:69
SELECTCURDATE()CURRENT_DATE()=CURDATE()fortimeuseSELECT
CURTIME()CURRENT_TIME()=CURTIME()
Questions:70 WhataretheadvantagesanddisadvantagesofCascadingStyleSheets?
Answer:70
ExternalStyleSheetsAdvantagesCancontrolstylesformultipledocumentsatonce.
ClassescanbecreatedforuseonmultipleHTMLelementtypesinmanydocuments.
Selectorandgroupingmethodscanbeusedtoapplystylesundercomplex
contextsDisadvantagesAnextradownloadisrequiredtoimportstyleinformationfor
eachdocumentTherenderingofthedocumentmaybedelayeduntiltheexternalstyle
sheetisloadedBecomesslightlyunwieldyforsmallquantitiesofstyle
definitionsEmbeddedStyleSheetsAdvantagesClassescanbecreatedforuseon
multipletagtypesinthedocument.Selectorandgroupingmethodscanbeusedto
applystylesundercomplexcontexts.Noadditionaldownloadsnecessarytoreceive
styleinformationDisadvantagesThismethodcannotcontrolstylesformultiple

http://school4php.blogspot.in/2011/10/100phpinterview.html

6/10

1/28/2015

AdvancedPHP:100PHPInterviewQuestionsandAnswers
documentsatonceInlineStylesAdvantagesUsefulforsmallquantitiesofstyle
definitions.Canoverrideotherstylespecificationmethodsatthelocallevelsoonly
exceptionsneedtobelistedinconjunctionwithotherstylemethodsDisadvantages
Doesnotdistancestyleinformationfromcontent(amaingoalofSGML/HTML).Can
notcontrolstylesformultipledocumentsatonce.Authorcannotcreateorcontrol
classesofelementstocontrolmultipleelementtypeswithinthedocument.Selector
groupingmethodscannotbeusedtocreatecomplexelementaddressingscenarios
Questions:71 WhattypeofinheritancethatPHPsupports?
Answer:71
InPHPanextendedclassisalwaysdependentonasinglebaseclass,thatis,
multipleinheritanceisnotsupported.Classesareextendedusingthekeyword
'extends'.
Questions:72 WhatisthedifferencebetweenPrimaryKeyandUniquekey?
Answer:72
PrimaryKey:Acolumninatablewhosevaluesuniquelyidentifytherowsinthetable.
AprimarykeyvaluecannotbeNULL.UniqueKey:UniqueKeysareusedtouniquely
identifyeachrowinthetable.Therecanbeoneandonlyonerowforeachuniquekey
value.SoNULLcanbeauniquekey.Therecanbeonlyoneprimarykeyforatable
buttherecanbemorethanoneuniqueforatable.
Question:73 whatisgarbagecollection?defaulttime?refreshtime?
Answer:73
GarbageCollectionisanautomatedpartofPHP,IftheGarbageCollectionprocess
runs,itthenanalyzesanyfilesinthe/tmpforanysessionfilesthathavenotbeen
accessedinacertainamountoftimeandphysicallydeletesthem.GarbageCollection
processonlyrunsinthedefaultsessionsavedirectory,whichis/tmp.Ifyouoptto
saveyoursessionsinadifferentdirectory,theGarbageCollectionprocesswillignore
it.theGarbageCollectionprocessdoesnotdifferentiatebetweenwhichsessions
belongtowhomwhenrun.Thisisespeciallyimportantnoteonsharedwebservers.If
theprocessisrun,itdeletesALLfilesthathavenotbeenaccessedinthedirectory.
Thereare3PHP.inivariables,whichdealwiththegarbagecollector:PHPinivalue
namedefaultsession.gc_maxlifetime1440secondsor24minutes
session.gc_probability1session.gc_divisor100
Questions:74 Whataretheadvantages/disadvantagesofMySQLandPHP?
Answer:74
Bothofthemareopensourcesoftware(sofreeofcost),supportcrossplatform.php
isfasterthenASPandJSP.
Questions:75 WhatisthedifferencebetweenGROUPBYandORDERBYinSql?
Answer:75
ORDERBY[col1],[col2],,[coln]TelsDBMSaccordingtowhatcolumnsitshould
sorttheresult.Iftworowswillhawethesamevalueincol1itwilltrytosortthem
accordingtocol2andsoon.GROUPBY[col1],[col2],,[coln]TelsDBMStogroup
resultswithsamevalueofcolumncol1.YoucanuseCOUNT(col1),SUM(col1),
AVG(col1)withit,ifyouwanttocountallitemsingroup,sumallvaluesorview
average
Questions:76 Whatisthedifferencebetweencharandvarchardatatypes?
Answer:76
Setchartooccupynbytesanditwilltakenbytesevenifurstoringavalueofnm
bytesSetvarchartooccupynbytesanditwilltakeonlytherequiredspaceandwill
notusethenbyteseg.namechar(15)willwaste10bytesifwestore'romharshan',if
eachchartakesabyteeg.namevarchar(15)willjustuse5bytesifwestore
'romharshan',ifeachchartakesabyte.rest10byteswillbefree.
Questions:77 Whatisthefunctionalityofmd5functioninPHP?
Answer:77
Calculatethemd5hashofastring.Thehashisa32characterhexadecimalnumber.I
useittogeneratekeyswhichIusetoidentifyusersetc.IfIaddrandomno
techniquestoitthemd5generatednowwillbetotallydifferentforthesamestringI
amusing.
Questions:78 HowcanIloaddatafromatextfileintoatable?
Answer:78
Questions:79
Answer:79
Questions:80
Answer:80
Questions:81
Answer:81

Questions:82
Answer:82

youcanuseLOADDATAINFILEfile_namesyntaxtoloaddatafromatextfile.but
youhavetomakesurethata)dataisdelimitedb)columnsanddatamatchedcorrectly
HowcanweknowthenumberofdaysbetweentwogivendatesusingMySQL?
SELECTDATEDIFF("20070307","20050101")
HowcanweknowthenumberofdaysbetweentwogivendatesusingPHP?
$date1=date("Ymd")$date2="20060815"$days=(strtotime($date1)
strtotime($date2))/(60*60*24)
HowweloadallclassesthatplacedindifferentdirectoryinonePHPFile,
meanshowtodoautoloadclasses
byusingspl_autoload_register('autoloader::function')Likebelowclassautoloader{
publicstaticfunctionmoduleautoloader($class){$path=
$_SERVER['DOCUMENT_ROOT']."/modules/{$class}.php"if(is_readable($path))
require$path}publicstaticfunctiondaoautoloader($class){$path=
$_SERVER['DOCUMENT_ROOT']."/dataobjects/{$class}.php"if
(is_readable($path))require$path}publicstaticfunctionincludesautoloader($class){
$path=$_SERVER['DOCUMENT_ROOT']."/includes/{$class}.php"if
(is_readable($path))require$path}}
spl_autoload_register('autoloader::includesautoloader')
spl_autoload_register('autoloader::daoautoloader')
spl_autoload_register('autoloader::moduleautoloader')
HowmanytypesofInheritancesusedinPHPandhowweachieveit
AsfarPHPconcernitonlysupportsingleInheritanceinscripting.wecanalsouse
interfacetoachievemultipleinheritance.

http://school4php.blogspot.in/2011/10/100phpinterview.html

7/10

1/28/2015

AdvancedPHP:100PHPInterviewQuestionsandAnswers
Questions:83 PHPhowtoknowuserhasreadtheemail?
Answers:83 UsingDispositionNotificationTo:inmailheaderwecangetreadreceipt.Addthe
possibilitytodefineareadreceiptwhensendinganemail.Itsquite
straightforward,justeditemail.php,andaddthisatvarsdefinitions:var$readReceipt
=nullAndthen,atcreateHeaderfunctionadd:if(!empty($this>readReceipt))
{$this>__header.=DispositionNotificationTo:.$this
>__formatAddress($this>readReceipt).$this>_newLine}
Questions:84 Whataredefaultsessiontimeandpath?
Answers:84 defaultsessiontimeinPHPis1440secondsor24minutesDefaultsessionsave
pathidtemporaryfolder/tmp
Questions:85 howtotrackuserloggedoutornot?whenuserisidle?
Answers:85 Bycheckingthesessionvariableexistornotwhileloadingthpage.Asthesession
willexistlongerastillbrowsercloses.Thedefaultbehaviourforsessionsistokeepa
sessionopenindefinitelyandonlytoexpireasessionwhenthebrowserisclosed.
Thisbehaviourcanbechangedinthephp.inifilebyalteringtheline
session.cookie_lifetime=0toavalueinseconds.Ifyouwantedthesessiontofinish
in5minutesyouwouldsetthistosession.cookie_lifetime=300andrestartyour
httpdserver.
Questions:86 howtotracknoofuserloggedin?
Answers:86 wheneverauserlogsintracktheIP,userIDetc..andstoreitinaDBwithaactive
flagwhilelogoutorsesionexpiremakeitinactive.Atanytimebycountingtheno:of
activerecordswecangettheno:ofvisitors.
Questions:87 inPHPforpdfwhichlibraryused?
Answers:87 ThePDFfunctionsinPHPcancreatePDFfilesusingthePDFliblibraryWithversion
6,PDFliboffersanobjectorientedAPIforPHP5inadditiontothefunctionoriented
APIforPHP4.ThereisalsothePandamodule.FPDFisaPHPclasswhich
allowstogeneratePDFfileswithpurePHP,thatistosaywithoutusingthePDFlib
library.FfromFPDFstandsforFree:youmayuseitforanykindofusageandmodify
ittosuityourneeds.FPDFrequiresnoextension(exceptzlibtoactivatecompression
andGDforGIFsupport)andworkswithPHP4andPHP5.
Questions:88 forimageworkwhichlibrary?
Answers:88 wewillneedtocompilePHPwiththeGDlibraryofimagefunctionsforthistowork.
GDandPHPmayalsorequireotherlibraries,dependingonwhichimageformatsyou
wanttoworkwith.
Questions:89 whatisdesignpattern?singletonpattern?
Answers:89 Adesignpatternisageneralreusablesolutiontoacommonlyoccurringproblemin
softwaredesign.TheSingletondesignpatternallowsmanypartsofaprogramto
shareasingleresourcewithouthavingtoworkoutthedetailsofthesharing
themselves.
Questions:90 whataremagicmethods?
Answers:90 Magicmethodsarethemembersfunctionsthatisavailabletoalltheinstanceofclass
Magicmethodsalwaysstartswith"__".Eg.__constructAllmagicmethodsneedsto
bedeclaredaspublicTousemagicmethodtheyshouldbedefinedwithintheclassor
programscopeVariousMagicMethodsusedinPHP5are:__construct()__destruct()
__set()__get()__call()__toString()__sleep()__wakeup()__isset()__unset()
__autoload()__clone()
Questions:91 whatismagicquotes?
Answers:91 MagicQuotesisaprocessthatautomagicallyescapesncomingdatatothePHP
script.Itspreferredtocodewithmagicquotesoffandtoinsteadescapethedata
atruntime,asneeded.ThisfeaturehasbeenDEPRECATEDasofPHP5.3.0and
REMOVEDasofPHP6.0.0.Relyingonthisfeatureishighlydiscouraged.
Questions:92 whatiscrosssitescripting?SQLinjection?
Answers:92 Crosssitescripting(XSS)isatypeofcomputersecurityvulnerabilitytypicallyfound
inwebapplicationswhichallowcodeinjectionbymaliciouswebusersintotheweb
pagesviewedbyotherusers.ExamplesofsuchcodeincludeHTMLcodeandclient
sidescripts.SQLinjectionisacodeinjectiontechniquethatexploitsasecurity
vulnerabilityoccurringinthedatabaselayerofanapplication.Thevulnerabilityis
presentwhenuserinputiseitherincorrectlyfilteredforstringliteralescapecharacters
embeddedinSQLstatementsoruserinputisnotstronglytypedandthereby
unexpectedlyexecuted
Questions:93 whatisURLrewriting?
Answers:93 UsingURLrewritingwecanconvertdynamicURltostaticURLStaticURLsare
knowntobebetterthanDynamicURLsbecauseofanumberofreasons1.Static
URLstypicallyRankbetterinSearchEngines.2.SearchEnginesareknowntoindex
thecontentofdynamicpagesalotslowercomparedtostaticpages.3.StaticURLs
arealwaysmorefriendlierlookingtotheEndUsers.alongwiththiswecanuseURL
rewritinginaddingvariables[cookies]totheURLtohandlethesessions.
Questions:94 whatisthemajorphpsecurityhole?howtoavoid?
Answers:94 1.Neverinclude,require,orotherwiseopenafilewithafilenamebasedonuserinput,
withoutthoroughlycheckingitfirst.2.Becarefulwitheval()Placinguserinputted
valuesintotheeval()functioncanbeextremelydangerous.Youessentiallygivethe
malicioususertheabilitytoexecuteanycommandheorshewishes!3.Becareful
whenusingregister_globals=ONItwasoriginallydesignedtomakeprogrammingin
PHPeasier(andthatitdid),butmisuseofitoftenledtosecurityholes4.Neverrun
unescapedqueries5.Forprotectedareas,usesessionsorvalidatetheloginevery

http://school4php.blogspot.in/2011/10/100phpinterview.html

8/10

1/28/2015

AdvancedPHP:100PHPInterviewQuestionsandAnswers
time.6.Ifyoudontwantthefilecontentstobeseen,givethefilea.php
extension.
Questions:95 whetherPHPsupportsMicrosoftSQLserver?
Answers:95 TheSQLServerDriverforPHPv1.0isdesignedtoenablereliable,scalable
integrationwithSQLServerforPHPapplicationsdeployedontheWindowsplatform.
TheDriverforPHPisaPHP5extensionthatallowsthereadingandwritingofSQL
ServerdatafromwithinPHPscripts.usingMSSQLorODBCmoduleswecan
accessMicrosoftSQLserver.
Questions:96 whatisMVC?whyitsbeenused?
Answers:96 Modelviewcontroller(MVC)isanarchitecturalpatternusedinsoftwareengineering.
Successfuluseofthepatternisolatesbusinesslogicfromuserinterface
considerations,resultinginanapplicationwhereitiseasiertomodifyeitherthevisual
appearanceoftheapplicationortheunderlyingbusinessruleswithoutaffectingthe
other.InMVC,themodelrepresentstheinformation(thedata)oftheapplicationthe
viewcorrespondstoelementsoftheuserinterfacesuchastext,checkboxitems,and
soforthandthecontrollermanagesthecommunicationofdataandthebusiness
rulesusedtomanipulatethedatatoandfromthemodel.WHYITSNEEDEDIS1
Modularseparationoffunction2Easiertomaintain3ViewControllerseparation
means:ATweakingdesign(HTML)withoutalteringcodeBWebdesignstaff
canmodifyUIwithoutunderstandingcode
Questions:97 whatisframework?howitworks?whatisadvantage?
Answers:97 Ingeneral,aframeworkisarealorconceptualstructureintendedtoserveasa
supportorguideforthebuildingofsomethingthatexpandsthestructureinto
somethinguseful.Advantages:ConsistentProgrammingModelDirectSupportfor
SecuritySimplifiedDevelopmentEffortsEasyApplicationDeploymentand
Maintenance
Questions:98 whatisCURL?
Answers:98 CURLmeansClientURLLibrarycurlisacommandlinetoolfortransferringfileswith
URLsyntax,supportingFTP,FTPS,HTTP,HTTPS,SCP,SFTP,TFTP,TELNET,
DICT,LDAP,LDAPSandFILE.curlsupportsSSLcertificates,HTTPPOST,HTTP
PUT,FTPuploading,HTTPformbasedupload,proxies,cookies,user+password
authentication(Basic,Digest,NTLM,Negotiate,kerberos),filetransferresume,
proxytunnelingandabusloadofotherusefultricks.CURLallowsyoutoconnectand
communicatetomanydifferenttypesofserverswithmanydifferenttypesof
protocols.libcurlcurrentlysupportsthehttp,https,ftp,gopher,telnet,dict,file,and
ldapprotocols.libcurlalsosupportsHTTPScertificates,HTTPPOST,HTTPPUT,
FTPuploading(thiscanalsobedonewithPHPsftpextension),HTTPform
basedupload,proxies,cookies,anduser+passwordauthentication.
Questions:99 whatisPDO?
Answers:99 ThePDO(PHPDataObjects)extensiondefinesalightweight,consistentinterface
foraccessingdatabasesinPHP.ifyouareusingthePDOAPI,youcouldswitchthe
databaseserveryouused,fromsayPgSQLtoMySQL,andonlyneedtomakeminor
changestoyourPHPcode.WhilePDOhasitsadvantages,suchasaclean,simple,
portableAPIbutitsmaindisadvantageisthatitdoesn'tallowyoutouseallofthe
advancedfeaturesthatareavailableinthelatestversionsofMySQLserver.For
example,PDOdoesnotallowyoutouseMySQL'ssupportforMultipleStatements.
JustneedtousebelowcodeforconnectmysqlusingPDOtry{$dbh=new
PDO("mysql:host=$hostnamedbname=databasename",$username,$password)
$sql="SELECT*FROMemployee"foreach($dbh>query($sql)as$row){print
$row['employee_name'].''.$row['employee_age']}}catch(PDOException$e){
echo$e>getMessage()}
Questions:100 WhatisPHP'smysqliExtension?
Answers:100 Themysqliextension,orasitissometimesknown,theMySQLimprovedextension,
wasdevelopedtotakeadvantageofnewfeaturesfoundinMySQLsystemsversions
4.1.3andnewer.ThemysqliextensionisincludedwithPHPversions5andlater.The
mysqliextensionhasanumberofbenefits,thekeyenhancementsoverthemysql
extensionbeing:=>Objectorientedinterface=>SupportforPreparedStatements
=>SupportforMultipleStatements=>SupportforTransactions=>Enhanced
debuggingcapabilities=>Embeddedserversupport
PostedbyNagaRajuDanneat8:25AM

Recommend this on Google

Nocomments:
PostaComment

http://school4php.blogspot.in/2011/10/100phpinterview.html

9/10

1/28/2015

AdvancedPHP:100PHPInterviewQuestionsandAnswers

Enteryourcomment...

Commentas:

Publish

GoogleAccount

Preview

NewerPost

Home

Subscribeto:PostComments(Atom)

Nagaraju.Simpletemplate.PoweredbyBlogger.

http://school4php.blogspot.in/2011/10/100phpinterview.html

10/10

You might also like