0% found this document useful (0 votes)
99 views8 pages

WT Unit 1 - CH 2

This document discusses various methods of handling files in PHP, including opening, reading, writing, appending, deleting, and listing files and directories. Some key functions mentioned are fopen(), fread(), fwrite(), fclose(), unlink(), scandir(), and is_file(). Both text and binary files are addressed.

Uploaded by

raks
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)
99 views8 pages

WT Unit 1 - CH 2

This document discusses various methods of handling files in PHP, including opening, reading, writing, appending, deleting, and listing files and directories. Some key functions mentioned are fopen(), fread(), fwrite(), fclose(), unlink(), scandir(), and is_file(). Both text and binary files are addressed.

Uploaded by

raks
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/ 8

ch2: hil handing

ile oponalions

0 Beading
puads jh aud Lurhis l
eacl hile Cjuncben so a

th output koulle
iocumtw bau b t fil callid "hbdichonany "
olord n SouWn

AJAY 1pmhronau huosipt Cud KML


csS Cascaduuig slql sheds
HIML Hypeu tert Havk up lamqvag

To rudd he ahove

29php
echo ead lle ('wab dieh
onay Ixt ");

Dulput
AJAY: aymchnon ou awaocip- ond XML
CSS Cacadi
Sut Shed HIML Hyperlexk
masukup langvag

opeing
fopen ) uncuen w suoud to
ope
ta
php clie
Smy ile-fopen ("wcbdichionany trE""7) ov
'Unable Fo open ile !J

echu fread (Sy u ,


AleSge ( "uebdiHonany. rtD)
Pclose ($myhle )

9>

aayrdhuonauo fauaecipt aud


HL Css=
oulput AJAV
Su HTHL Hypaloet rmaxkup langvage
Cas cacduig
Shy

d d e a t a q n d z

dwonplin
Mods
to vead onlyy
open a feb

opena joruwul orl


(cof s sinénqpt-)
open a fil (
uvut ornly

Cveatuo e rw fu (s7 wrulh only

24wct
Cpen aeb y Puad
uenil /ead
pen a l Jo
w+

a l 5 ead/uwii
Open
/uwnt l
Oventun a i j vand
y+
Tad ) Jumolion
ado rom am pem l
panamelun donlauns name
)th tread t)'3 jvialt gndr
súad om aud Ihe putame
t h fl bn 0 . read
mai mu
b l i s to

er
road ($yile,Glesige ('Webebchionauy trt "))

Closing ()
ded
Lo
)Hclase.l) huncion
) Jclose t) 9uquinsh namt g the hla lbr a Varu'ab

heat holds Uu hilenamt)


we
uwart to close

9 php
$mufrle lopen ("wchoich onany tt", *)
S m t odk to be ouecutd

Pclose Cny hu)

laets C)- Road Iinqt Liu


epf c)-check end-o-il
qehe C)-Read Singl chanacte

Creabing le

)open ) - o d
0
Cvtat a jil
lhat dos mol eidt
you aoe open () on
a jdh
il ull treau it, guun
Lhiat ha flh ns opentd
OY uunifing
(w) b appeunding (a)

myhle fopen ("lsthe Irt""w")

Datking
)Furile ) n oed to ue uit to a h
fuvuh () onlains
mam
o
panamlt ol
)dhe oiet
hilk to uwule lke nd
into
panaietn
t

lo be wwutlen
lhe alaing

)
phpi 'nuwGile Iet", "w")or die
Smyhle lopun ( 'Onable to open lu !

txt John Doc \n"


pisis
fonte ( fmuyhile ,5txt );
Stxt Jant Doe Nn' t
Aorite ( $myile, txt) hesl,
lose (Smyile)
9>i

opn rwfile tvt)


) output ( whun
u

John Doc
Janc Doc a
Appencling
auwuh aud
) funcim an und .or both
)uwntt
appud data into ll

9php
9p: Fopern (data . txt,'a')
Fwrite (3fp Jhis is addihonal ')
kuoile (9p 'appeuding dala )
telose(Stp)
tcho" appoudud Sueeapully"

outpul: data.Ixt
weltpme to php Jhus is aditinal appeuting dala
Su ct eolully
ile appudud

deleting
)Dnink ) hunclion u d to olulilu any pil

slhur yunim acepl only ont anqumesit

) qencmalin EWARING Lul vvwr i u in mot


deletrd elwms TRDE i l in delulid oucuwul
oucu ru
olheuise FALSE

) Synax
bool unlink (Sing $hlename [$o orc. ontest
9php
Shalus= umuich ('data Ixt');
if /4Stao)

echo "File dleted Succeoully

else "Sovny!

oulput
4ile deleted Suceiosulli4

Aisting oluoveclories
waut to lhu felo aucd
Somelimu, you might qet
olurclonies n a duneclöny

)Scandir () uoed jor huà purpase


o tis
uaill med lo Supply path q diveclbry
)You
uncion
an away lat lonlaund name
o llua
dlselwrns
anctoritaPugusid

chelth Lehelbo an
ilm
IsPile () u ó d to
douclon ad

° php
unchion getDirelontent (sdi)
ist Sandir (9sli)
lor tach (Sust as $Valu)

if is-Ple ( Valu ))
echo "rle. Valu."2br/s",
else
coho div:.$Valuu.'2br/>'

extGiles_and Binasu jils


Teaclen inD om etile
? php
fh open 'ile mame Ixt', ' )
ohile ($Line lqets (SPh))

echo (Sune)
Pclose C$ Ph );

) All u preuioualy disussed Hlu handling au lov


Ioxt ies
Bina_tu
) i a Jeh alord n oinany ormat
:)a inany l lomputvt-vadabl out mot huummam
un
Yadabu Al entuulab progvamo a u alond
m o s n m u ' e clala hihs
binasny zelo, Muy a u

Howeuw Tead il au iloved un a


horm (ueually
puadabe
That io humam-
A SCI1)

)Readug lemany dala

php
S -
lopem ( 'data Iet', 'vb')

Lohile C(feof ($P

(Ss = Prad CBl,52))

Print r eppunpack ('ieid /icag , $5))


3

P Close ($t)

You might also like