Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Самостоятел_2(2)

.pdf
Скачиваний:
6
Добавлен:
09.02.2016
Размер:
575.36 Кб
Скачать

0&

*

 

]iohn%&

<?php

 

 

 

 

$fp = file("counter.txt");

 

 

 

 

echo '

: '.count($fp);

 

 

 

?>

 

 

 

 

1&

 

 

 

 

<? php$ fp = fopen ("counter.txt", 'a'); flock ($ fp, LOCK_EX&7++

 

fwrite ($ fp,

&7flock ($ fp, LOCK_UN&7++

fclose ($ fp); ?>

 

 

6)

<? php

$ num_stroka = 5; / /

5

$

file = file ("counter.txt"); / /

 

for ($ i = 0; $ i <sizeof ($ file); $ i + +)

if ($ i == $

num_stroka) unset ($ file [$ i]);$ fp = fopen ("counter.txt", "w"); fputs ($ fp, implode ("", $ file));

fclose ($ fp);

?>7)

.

 

cf_nsj_%&)

 

8;jbj$

mytype = filetype ("counter.txt");

_]bi

6*!gsnsj_7?>

 

 

 

©

 

:file -

dir -

ink -

 

fifo - fifo-

block -

-

char -

-

 

unknown -

8)

 

 

,

 

stat ()

 

 

 

 

<?php

 

 

 

 

 

$filename = stat("counter.txt"); echo "<pre>"; print_r($filename);

echo "</pre>";

?>

 

 

 

5&

)

 

nloh][n_%&8;jbj $ fp = fopen ("counter.txt",

$[$&7++

©

nloh][n_%!j),&++

?>

 

 

 

,&

 

)

cf_]ncg_%&*

 

Qhcrncg_mn[gj*

 

<?php

 

 

 

echo filectime("counter.txt"); ?>

 

 

 

 

kc

 

*

©

;

 

.*

©

;

 

/*

*

 

 

0*

*

 

 

1*

*

 

 

41

 

oc

co

c c

k k)

 

 

 

 

 

 

 

 

 

 

 

c

 

LDL*

 

 

 

 

k

 

 

 

 

 

 

1.

 

 

 

 

 

 

 

2.

 

 

 

 

 

 

 

3.

 

 

 

 

 

 

 

4.

 

 

 

 

 

 

 

5.

 

 

 

 

 

 

 

T

c c:

 

 

 

 

 

 

1.

©

- }LDL dMo_ls

)

).,

)//0 *

 

2.

 

- }

)

6

).,,

).44

*

3.

**

- }

0) 6}

 

).,,

)/1.

*

 

 

 

k k e k

opendir -

 

*

 

oh]ncih^_f_n_if^_l%! &u

 

%!

9ij_h^cl%! &u

 

% © 99%!

9l_[^^cl%!

&u

%!

8: * !

8: *&u

 

%!

9 *#

7# 7!

9 *&u

\!h7

}

%-Z %! *$+$*! &u deletefolder($ .'/'.$ );

}

}

}

} }

deletefolder("1");

 

closedir -

 

 

*

$;

 

 

 

%!9ij_h^cl%![&u

7 %]fim_^cl%!&99 © &u *7

}

 

 

 

}

 

 

 

u

 

 

 

 

7

 

 

}

 

 

 

readdir -

 

 

*

oh]ncih^_f_n_if^_l%! &u

 

%!

9ij_h^cl%! &u

 

% © 99%!

9l_[^^cl%!

&u

%!

8: * !

8: *&u

 

%!

9 *#

7# 7!

9 *&u

\!h7

}

 

%-Z

%! *$+$*! &u

^_f_n_if^_l%!

*$+$*! &7 w w w ww

deletefolder("1");

 

rmdir -

*

$;

 

rmdir($a);

 

42

mkdir -

 

 

 

 

 

 

$a =("./AppA");

 

 

 

 

 

 

mkdir($a);

 

 

 

 

 

 

file_exists -

 

TRUE,

 

' ,

filename,

;

FALSE

 

 

.

 

 

 

$default_dir = "X:\home\p2\www\?b,/7+

 

 

 

c%cf_Z_rcmnm%!^_[ofnZ^cl&u+

 

 

 

 

lg^cl%!^_[ofnZ^cl&7+

 

 

 

 

 

}

 

 

 

 

 

 

else {

 

 

 

 

 

 

ge^cl%!^_[ofnZ^cl&7+

 

 

 

 

 

}

 

 

 

 

 

 

dirname -

 

*

 

 

 

$default_dir = "X:\home\p2\www\?b,/7+

 

 

 

if (file_exists($default_dir)){

 

 

 

 

$a=dirname($default_dir);

 

 

 

 

 

echo $a; //

X:\home\p2\www

 

 

 

 

}

 

 

 

 

 

 

is_dir -

 

 

 

*

nlo_

$

 

 

 

*

 

 

 

$a =("./Ch16");

 

 

 

 

 

 

if(!($c= is_dir($a))) die ("

 

"!);

 

 

 

echo $c;

 

 

 

 

 

 

 

 

Pcec

ek c

co

k

 

1.

 

 

 

 

)

 

)

©

 

 

 

 

*

2.

 

 

*

kc

 

 

 

 

 

 

 

 

1.

 

*

 

 

 

 

2.

 

*

 

 

 

 

3.

 

 

 

 

*

 

4.

 

 

*

 

 

 

5.

 

*

 

 

 

 

6.

 

;

 

 

 

 

43

 

 

Po ek o

-

ek ck 4 4

 

 

 

oc

co

c c

 

k k)

 

 

 

 

 

 

 

 

 

 

 

 

c

 

 

)

 

 

 

 

)

 

)

 

 

 

*

 

 

k

 

 

 

 

 

 

 

1.

 

 

 

 

 

 

 

 

2.

 

 

 

 

 

 

 

 

3.

 

 

 

 

 

 

 

 

4.

 

 

 

 

 

 

 

 

5.

 

 

 

 

 

 

 

 

T

c c:

 

 

 

 

 

 

 

1.

©

- }LDL dMo_ls

 

)

).,

)//0 *

 

2.

 

- }

)

 

6

).,,

).44

*

3.

**

- }

0) 6}

 

 

).,,

)/1.

*

 

 

 

k

e o

 

 

 

 

 

©

©

©

 

LDL -

 

 

*

 

)

)

 

 

)

 

 

 

 

 

*

©

-

 

*

 

 

 

 

 

 

 

 

*

 

 

-

)

 

 

*

)

 

 

)

 

*

 

 

 

 

 

 

 

)

 

 

)

 

%

) Ic]limin

Sil^&

 

 

©

*

)

 

-

6

 

)

)

 

-

 

*

 

 

 

)

 

 

 

 

;

)

 

 

 

 

 

 

 

 

*

 

 

) -

 

 

%<&

*

 

-

 

©

*

 

 

 

 

 

 

 

-

 

 

*

 

©

 

©

 

 

)

 

 

6

 

-

 

 

*

©

 

 

 

)

 

 

 

*

 

 

 

 

 

 

 

 

©

-

 

)

 

 

 

*

 

 

)

 

)

 

*

 

 

 

 

 

 

-

 

-

*

 

 

*

©

©

 

)

 

 

-

 

 

 

*

6

 

 

 

+

 

 

 

 

 

 

 

 

a

 

 

 

 

 

 

 

 

+

 

 

 

 

 

 

 

 

\x41 - ©

$=$

 

 

 

 

 

 

 

\x09 -

 

 

 

 

 

 

 

 

 

-

)

 

6

 

 

 

 

ACZms

 

 

 

 

 

 

 

 

 

 

-

 

 

©

 

 

)

 

 

© *

)

 

 

 

6

 

44

 

 

 

-

*

 

)

 

 

 

 

 

 

 

*

 

 

 

 

 

6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

()

 

© *

 

*

 

 

 

 

 

 

 

|

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

^

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

$

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

\n

 

 

 

%

,r,=&

 

 

 

 

 

\r

 

 

 

%

 

,r,@&

 

 

 

 

 

\t

 

 

 

%

,r,5&

 

 

 

 

 

 

\xhh

 

 

 

 

,rbb)

\r0.

 

 

 

 

 

'B'

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

.

 

*

-

*

 

 

 

 

 

 

 

\d

 

%,-9)

 

 

 

 

 

 

 

 

\D

 

 

% -

 

,-9)

 

 

 

 

 

 

\s

 

©

 

%

 

&

 

 

 

 

 

\S

 

©

 

% )

)

 

 

\s)

 

 

 

\w

 

 

 

% )

 

 

*

 

)

 

 

 

 

 

 

%$Z$&

 

 

 

 

 

 

 

\W

 

)

 

)

\w

 

 

 

 

 

 

 

 

 

 

©

$ *"d" - digit (

), "s" - symbol (

),

 

"w" - word (

).

 

-

 

 

 

*

 

 

 

 

 

 

 

 

4.)

 

 

- .,,5*

 

 

 

 

 

 

 

6

 

 

 

 

 

 

 

\d\d\d\d -

4. .,,5

 

 

 

 

 

 

 

 

\D -

)

 

 

 

 

 

 

 

 

 

\s -

 

 

*

 

 

 

 

 

 

 

©

 

 

 

©

)

 

)

©

 

 

 

 

 

*

©

©

)

 

 

 

 

 

 

© 6

 

 

 

 

 

 

 

 

 

 

 

[0-9] -

 

-

 

% ©) \d)

 

 

 

 

 

 

 

[0,2,4,6,8] -

 

 

 

 

 

 

 

 

 

 

 

[A - Za - z0 - 9] -

 

-

 

% -

 

&

*

 

 

 

 

)

©

\d\d\^W,).)0)2)4X

 

 

 

4.)

.,,5*

 

 

 

 

 

 

 

)

 

 

 

,).)0)2

 

 

8".

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*

 

 

 

 

 

 

-

 

 

)

)

 

 

 

 

 

 

*

 

 

©

uw*

©

 

 

6

 

 

*

 

 

6

 

 

 

 

 

 

{X}

 

 

 

 

 

 

 

 

 

 

-

 

 

)

 

 

 

*

 

©

 

 

\d{4}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*

 

 

 

 

 

 

 

 

-

 

*

 

 

 

 

 

 

 

{X, Y}

+

{,Y}

+

{X,}

45

T-

 

) U-

 

 

*

6

 

 

 

 

\d{2,4}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*

©

)

 

 

 

 

©

*

6

 

 

 

 

 

 

\w{3,}

-

*

 

 

 

 

 

 

 

 

\d{,5}

-

)

)

 

$ *

 

 

 

 

 

 

 

©

 

 

)

 

6

 

 

 

W -

-

Xu)/w

 

 

 

 

 

 

 

 

 

 

 

 

 

)

 

%

)

)

)

)

 

&

 

 

 

 

 

 

 

 

 

 

©

 

 

-

 

6' %

&)( %

&

;

%

 

&*

 

)

 

 

 

 

 

 

 

 

*

)

 

 

 

©

 

 

)

 

 

 

 

%

&)

-

%

 

&*

 

 

 

'

-

 

 

)

 

 

 

 

\w*

 

 

 

 

 

 

 

 

 

 

 

 

-

 

)

 

 

*

 

 

 

 

 

(

 

 

)

 

-

 

* * *

\d+

 

 

 

 

 

 

 

 

 

 

 

 

-

 

)

 

*

 

 

 

 

 

 

;

 

 

* **

 

 

 

 

\d?

 

 

 

 

 

 

 

 

 

 

 

 

-

 

)

 

*

 

 

 

 

 

 

 

 

 

'

(

© *

 

)

-

 

 

 

 

 

 

 

*

)

 

©6

\*(

 

 

 

 

 

 

 

 

 

)

 

) ©

 

 

*

 

 

 

 

;%

 

&

 

 

*

 

 

 

)

 

 

)

 

*

 

 

6

 

 

 

 

 

 

\*(;

 

 

 

 

 

 

 

 

 

 

*

 

 

 

 

 

 

 

-

*

-

 

)

 

 

 

 

*

 

 

)

©

 

)

 

6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

i

© ][m- chm_hmcncp_)

 

 

©

 

*

 

m

)

)

 

)

 

 

 

 

 

*

 

 

 

 

 

 

 

©

)

 

*

 

$Y$ $!$

 

 

 

 

*

©

 

 

)

 

 

 

 

©

*

 

 

 

 

 

 

s

 

$*$

 

 

 

 

* * *

 

 

 

© +*(+

 

 

)

)

*

©*

U

 

©

*

 

%

LDL&

Q

a)

%a -

 

 

al__^s)©

&*

 

 

 

 

*

©

 

 

)

 

*

46

email

 

[\.\-_A-Za-z0-9]+?@[\.\-A-Za-z0-9]+?[\ .A-Za-z0-9]{2,}

 

 

 

 

 

 

^\d{1,2}([-. /])\d{1,2}\1\d{2,4}$

 

 

 

 

 

 

 

 

[\d]{4}\.[\d]{2}

 

 

 

 

 

 

 

(?:8|\+7)? ?\(?(\d{3})\)? ?(\d{3})[ -]?(\d{2})[ -]?(\d{2})

 

 

 

 

 

©

/<tag>(.*)</tag>/Uis

 

 

Pcec

ek c

co

k

1.

*

 

 

 

 

 

 

kc

 

1.

 

*

 

 

2.

 

*

 

 

3.

 

 

*

 

4.

 

*

 

 

5.

*

 

 

 

47

oc

co c c

k k)

LDL

 

c

LDL

*

 

k

 

1.

2.

3.

4.

5.

T c c:

1.

©

- }LDL dMo_ls

)

)., )//0 *

 

2.

 

- }

) 6

).,,

).44

*

3.

**

- }

0) 6}

).,,

)/1.

*

 

 

 

 

 

 

k

e o

 

 

 

 

 

 

 

 

 

LDL

 

 

 

6

 

int preg_match (string pattern, string subject [, array matches]) -

 

 

,

subject

 

pattern.

1,

 

 

 

,

 

 

0.

'

 

-

matches,

 

 

 

 

 

 

 

-

 

 

.

 

 

 

 

 

 

 

 

int preg_match_all

(string pattern, string

subject, array

matches

[, int

order]) -

 

,

 

-

 

 

 

 

 

 

 

matches

 

 

.

 

 

 

 

 

 

 

 

 

mixed preg_replace

(mixed pattern,

mixed replacement,

mixed

subject

[, int

limit]) -

 

 

, preg_replace

 

 

 

 

,

 

 

.

 

 

 

 

 

 

 

*

 

 

 

 

mixed preg_replace_callback (mixed pattern, mixed callback, mixed subject [, int limit]) -

 

 

 

.

 

 

 

-

 

 

 

'

,

 

 

 

 

 

 

 

.

 

 

 

array preg_split (string pattern, string subject [, int limit [, int flags]]) -

 

 

explode()

split().

 

 

)

 

 

 

 

 

 

)

©

*

 

 

 

 

 

 

 

 

 

*

array preg_grep (string pattern, array input) -

 

 

 

 

*

 

 

 

 

 

 

 

)

 

 

)

 

)

 

*

 

 

 

 

 

 

 

 

 

 

 

Pcec

ek

c

co

 

k

 

 

1.

 

 

 

 

 

 

 

LDL

 

 

6

1) <?php

 

 

 

 

 

 

 

 

 

 

 

+

 

 

 

 

 

 

 

 

 

 

 

$value = "abcde 12345 klmnop";

 

 

 

 

 

 

 

 

+

 

 

 

 

 

 

 

 

 

 

 

$template = "/\w{5}/";

 

 

 

 

 

 

 

 

 

//

 

 

 

 

 

 

 

 

 

 

 

$result = preg_match($template, $value, $maches);

 

 

 

 

 

echo "

: $result<br>";

 

 

 

 

 

 

 

 

print_r($found);

 

 

 

 

 

 

 

 

 

 

?>

 

 

 

 

 

 

 

 

 

 

 

2) <?php

 

 

 

 

 

 

 

 

 

 

 

$text = "

\t\n\t\t

\n

\t

\n\n\n

 

";

 

 

 

echo "<b>

 

:</b>\n$text\n\n";

 

 

 

 

 

 

$text = preg_replace("/(\n \s{2,})/"," ",$text);

 

 

 

 

 

echo "<b>

 

:</b>\n$text";

 

 

 

 

 

 

+

)

 

 

 

 

 

 

 

 

 

48

+

?>

3)<?php

//©

$text = join(''file('my_text.txt'));

//

$words = preg_split("/\s+/s",$text);

+

print_r($words);

 

?>

 

kc

1.

int preg_match (string pattern, string subject [, array matches]).

2.

int preg_match_all (string pattern, string subject, array matches [, int order]).

3.

mixed preg_replace (mixed pattern, mixed replacement, mixed subject [, int limit]).

4.

mixed preg_replace_callback (mixed pattern, mixed callback, mixed subject [, int limit]).

5.

array preg_split (string pattern, string subject [, int limit [, int flags]]).

6.

array preg_grep (string pattern, array input).

49

 

 

o

ek o

e - PHP

cWEB

 

 

 

 

 

Po ek o

6.1 - 4 4 k co

e

 

 

 

 

oc

co

c

c

k k)

 

 

 

 

 

 

 

 

 

 

 

 

c

 

 

 

*

 

 

 

 

k

 

 

 

 

 

 

 

1.

 

 

 

 

 

 

 

 

2.

 

 

 

 

 

 

 

 

3.

 

 

 

 

 

 

 

 

4.

 

 

 

 

 

 

 

 

5.

 

 

 

 

 

 

 

 

T

c c:

 

 

 

 

 

 

 

1.

©

- }LDL dMo_ls

 

)

).,

)//0 *

 

2.

 

- }

 

) 6

).,,

).44

*

3.

**

- }

0) 6}

 

).,,

)/1. *

 

 

 

k

e o

 

 

 

 

 

 

%

 

/2*&

 

 

©

q_ -

 

 

*

 

)

 

 

)-

)

 

)

 

DPIH-

*

 

 

 

 

/2**

 

 

 

 

 

 

 

<?

+6header.tpl

+

6

LbjN_]cj_m*

+6.. .,,, *

$site_name = "PHPRecipes"; $site_email= "wjgnmore@hotrnail.com"; $site_path = "http://localhost/phprecipes"; ?>

<html>

<head>

<title> <? print $site_name; ?> </title> </head>

<body bgcolor="#7b8079" text="#ffffff" link="fe7d387" alink="#e7d387" vlink="#e7f0e4"> <table width="95%" cellpadding="0" cellspacing="0" border="1">

<tr>

<td valign = "top"> PHPRecipes

</td>

<td valign = "top" align="right">

<?

+

print date("F d, h: i a"); ?>

</td>

</tr>

</table>

)

)

©

)

%

)

&* =j[]b_

©

bnj*]ih

bn[]]_mm*

 

)

*njf6

 

 

 

50