The document contains a series of PHP-related questions and programming tasks, including creating classes and objects, types of inheritance, session and cookie management, and database operations. It also covers concepts like object cloning, introspection, and differences between GET and POST methods. Additionally, it includes code examples and explanations for various PHP functionalities.
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
0 ratings0% found this document useful (0 votes)
10 views14 pages
Php Questions
The document contains a series of PHP-related questions and programming tasks, including creating classes and objects, types of inheritance, session and cookie management, and database operations. It also covers concepts like object cloning, introspection, and differences between GET and POST methods. Additionally, it includes code examples and explanations for various PHP functionalities.
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
You are on page 1/ 14
Php
=~) PTT-2 Questions.
@1. Attemet Any Four.
t. Write. Syntax to create class and Object in Phe:
2. List types of inheritance
%. Justify need For cooling of transFormer -
& How to create Session Variable in Php-
5. How to vse of cookies in PhP:
6. List two database Openations -
as) Attempt any three
\. Write a Program For Cloning oF an object
9. Define Introspection: explain lt with enccumple .
3, Oiferente bebween GET And Post method -
4. Write a Phe Program to Set and Modify Cookies.
5B uote a Program to connect PhP with mysat.
1 :| i ad
1 a . Peetof
J = [ees]
r —$———— = a.
Qa] Write the syntax of Class and Obiect in Phe. ——
1 Class 3-_ - =
ay Suntan 7 rae yo
[| ee classnaimd ‘ 7 ot =
“vost prin = valle; Font ee od _
Fonehion Functionnamelamgs) is. =
“+ code. - ie
X ; =
PWS ho ' i 7 \ oar
ele ey yi Talgbins \ =
i _Sbject s- Ob pw Ta fue E
sbieody vicar brea doe AP (rer ear ind _
GUNA est. bona ob ene i _
$object= new Classname. : -
: Clags and abject Combine.
Suntory ¢—
ZT PhP”
Class Classname
é
fvar $ Property = Value 5
Public Function Function name ¢> i
mf oS) =
i iI code -
[3 .
aia=~ Gob)
|
fl
oh jamec) 5
Sob) 7 Show Message d }
a . :
2. Types oF inheritance in Phe-
1. Single Inheritance
2. Mutilevel Tnhoritance
3. Multiple Tnheritance.
4. Hienosrchical Tnheritance .
3. TustiFy the need For Coolina transformer
2= Teas)
Po ee
How to Create cession variable 1 Pn? _
Session variable can be Cok em *he help oF a
Php alebal variable + G-SESSTO — a
2,| Data in the Gossion ig Stored ‘in the Fava Lae
| Keys and values Palit: :
3 We Can Save any type OF data IN Sewven + _
_which Include array and abject . .
4. For example, we want to Store Usemname Tn.
the Session So tH can be accossec| Whomever Ihig 7
required throughout the Session
<2 phe
Gession-StartC)-
“A Cookies One used to tracking . the Pages
| QSESSTONT “Usomname'] = “alc
> ea z 7
5 HOW to vse oF Cookies In Phe a |
A cookie is a Small File thed the Somer ingor}
ON -LSer Computer - —
2/ Each time the Same Comeuter Tequosts apage.
with a browser Tt will Send the cooKio too
_w0d CON both Creaie And TeivWVE Cookie Taine
g._HITP 18 Stadelose Protocal = Cookies allows oc
apelication using.
A Cookie ia Often used to Wemtify ausor. |
1
_to track the Stale OF the ap)
small Files. Stored on User COMPUT ON.
_ visited by usar.
5 Two tyres oF Cookies a
E ke Gegsion Cookies —
Li | 2- Persistent Cookies. —=e) OR Cookie ig 4 Small piece oF “data in the Form of
Name- value Pair that is Sent by a web Sorvey
and. Stored by the browser on the client machine.
“OR.
“A A Cookie is G Small Piece of data Stored on the
USen's browser -
1S U8ed £0 | Temotioe information across
cred on the cliend-Gide go aveid
Guch as Lsemname that the ste can retrieve to
Personalize the Page when the User visit peste,
noxt time.
5. Tapes of Cookies.
1: Session Cockie Z
a. Persistemk Cookie:en —
Pe ;
@6\ List two oe
Hes es oe ee
my sqli_ ar Pocted-TOWS.O ey
L 2. musali=closec)
3. Muysali_ Conneclc) ~
mausqli- Paich-arrayl)
5. mysali- Felch-“as soc)
6
MUSQli= eTrOTC)
@2 Four marks Qvestions oe PR! ts
“\ Writ@a Progtam to Clenning an abject |
1. Object Cloning is the Process in Php Create a
copy oF AN objoct fs 4 ig
Syntax ¢- 2 3 Pa
ScoPy-object-name= clone Gobjectto-be- copied.
Ex g-
<2 Phe
Class. e+one Copy —
Public $datad 5
Poblic Fdaiag*
i Public tdaiaz + § -
5 ee
- _ — ; a
I 4 Obj= Nowlionery — j
| §coput= clonesobj 7 aqP|
— = SRE
| Sob} dataz= 9 with".
| Bobj > datos = "web" s
“S copy > adalat ““computen” » :
scopy > daiaes “Tr.
_ Scopy y Acdas =" portale!
he.
echo “ tobj -> datattobj > daiaztob}> dalaz \ni >
“copy 7 daiat $copy 7 data2tcoPy > data BAN
“PHP with we
Computer I+ Portal -
<2 HE aba
1 Class “Student
Fonction gekdaia C&nm, Syn)
1 tthis> ane = Sam iE :
$this> vollnmo=trn
a aain “asPlay ansae
= ee ahs name 5 a
[ echov The™name of clage in
Class- exists O—> retorng true if chaise entisty.
| bs—
Sek declared Classe
]
a. ga—cla
Za
> TAUMNE all classes
eihodsc}—> reiums all clase methods
5. Ok-Class-Vansc)—> returns the ligt class Properties —
Esl A y TetUTNS zi tie
—_&. Method. emiets(s> returns true if method enists-
a {g-Objeck-7_Retttins Trud if Passed Paxameler ig
On Object
TS. aak-cbject-varSO2s Gals the Properties oF Sven _
object: :
Ztehe
Clase’ Pareniclass
t a
Public troll |
___X\ Poblic Function Pasr- Fonction ()
— << phe~ Function testing -threet) : — _
return (t Tua 5 -
3 : 2
(FC Class_ existsC' Test’) - ie
2. St =NewTest0)} ; : _ [-
{| echo The Class is exists- _
J HTML Form Submission | :
4, Write Proatam to Set and Modify cookies, in
Phe”
= ;
BHP program fo Set
<2ehe
iF C1 issekC -COOKLE: Coser)
4
echo “Sorty, Cookie is not Pound|" 5)
% —_
Ose — =
I —
~ echo “Segyermanao/ hestnime &
lon Beet curvowuron ean
thin
7
Qs. write a Program to connect PHPuwith ca
Sr 3 Phe _ =
Sservername = “localhest” ial
S Username = “toot! s ; —
$Password=9 4 : :
Seonn = new mysaliC Ssenvername, Seema
Seassword) ; ;
iF C&conn—> connect— e707) BL T
___die C" Connection Failed =" dconn—s ox Conner estar)
: x
echo "Connected BoccoseFedg po
87 _ {
Ff ole 4- hs |
Connected) SvecesFally . VAN ies j
ie &- Used When eErTOT Occure th
en execution _
Stopped - oS i