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

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

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

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

 

 

*

)

$

 

 

© ) LDL

 

©

$

 

*

 

<?

 

 

 

 

 

 

 

 

 

8l:+'

 

6<br>

 

 

 

 

 

 

Add_sign –

 

 

 

 

 

 

 

8l:ObiqZn_rn#h^[mb7

 

'+

 

 

 

 

<br><br>function Add_sign($string,

 

 

 

 

 

 

$sign="

,

")<br>{<br> echo $string ". ".$sign;<br>}

 

 

 

<br>function Show_text()

 

 

 

 

 

 

u8l:_]bi

 

 

 

8l:78l:w8l:!oh]9 ObiqZn_rn78l:

+

 

 

)

 

 

ObiqZn_rn8l:!oh]%&78l:

 

+

 

 

ObiqZn_rn

 

 

 

 

 

 

8l:!oh] 9

=^^Zmcah7 8l: +

 

 

 

 

)

 

Add_sign< l:!oh]%

8l:&7

 

 

 

 

 

 

8l:+

 

=^^Zmcah

 

 

 

8l:;:8l:8l:

 

 

 

 

ObiqZn_rn

 

 

 

*

 

)

 

 

 

)

 

 

_]bi%&*

 

 

 

)

 

) _]bi%&)jlchn%&)ohm_n%&)ch]fo^_%&

 

©

 

 

 

*

 

6

 

 

 

 

<?<br>$func = "echo ";<br>$func("TEXT");<br>?><br>

 

 

 

 

 

 

 

6

 

 

 

 

 

 

Fatal error: Call to undefined function: <br> echo() in<br>

 

 

 

c:\users\...\tasks\func\var_f.php on line 2<br>

 

 

 

 

 

 

)

 

 

 

 

 

 

 

 

 

-

 

 

 

 

)

 

*

 

 

 

Pcec

ek

c

co

k

 

 

1.

 

 

*

 

 

kc

 

 

 

 

 

 

 

 

 

 

 

 

*

 

 

*

 

 

 

 

 

 

.*

 

 

 

 

;

 

 

 

 

31

 

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

 

 

 

 

ch]fo^_)ch]fo^_Zih]_)l_kocl_ l_kocl_Zih]_

©

 

 

 

 

*

 

 

 

 

 

 

 

 

 

 

 

 

)

 

LDL-

 

 

*

 

-

LDL-

)

 

 

 

 

 

 

*

 

 

 

 

 

 

 

©

 

 

*

 

 

)

©

 

 

 

 

 

 

 

*

 

*

<?php /**

 

 

 

 

 

 

 

 

'

 

 

 

 

 

 

 

 

 

'<[onbil

 

 

 

 

 

 

 

 

*/

 

 

 

 

 

 

 

 

 

'

 

'+

 

 

 

 

 

 

 

function math_sq($num) { $result = $num * $num;

 

 

 

 

return $result; }

 

 

 

 

 

 

 

'

 

'+

 

 

 

 

 

 

 

function math_cube($num) {

 

 

 

 

 

 

 

$result = $num * $num *

$num; return $result;

 

 

 

 

 

}

 

 

 

 

 

 

 

 

 

%

 

©

g[nb*fc*jbj&

 

 

*

 

 

 

 

 

)

-

 

 

)

 

 

 

*

 

 

 

 

 

 

 

 

 

 

 

©

©

 

)

 

 

*

 

g[nbZ*

 

)

 

 

LDL

 

 

 

*

 

 

 

 

 

 

 

 

$

 

)

*

 

 

 

)

 

 

©

)

-

)

 

 

)

 

*

 

 

 

 

*

 

 

 

 

 

<?php

 

 

 

 

 

 

 

 

require_once

"math.lib.php";

 

 

 

 

 

 

 

echo math_cube(235); ?>

 

 

 

 

 

 

 

 

require_once

 

 

 

 

 

 

.

 

 

© ©

,

,

 

 

,

 

<?php (

 

)

 

?>.

 

 

 

 

 

 

32

 

Pcec

ek c co

k

1.

*

 

 

2.

 

kc

*

 

 

 

1.

 

*

 

2.

*

 

 

3.

 

*

 

4.

*

 

 

5.

- *

 

 

6.

 

*

 

33

 

 

 

Po

ek o

-

ckek

 

 

 

 

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

 

 

 

 

 

 

 

 

 

 

 

 

 

*

 

 

 

)

 

 

*

 

 

 

 

 

 

 

 

 

-

 

)

 

 

)

 

 

 

 

-

*

 

 

 

 

 

 

)

 

 

 

)

 

 

 

 

7

©

)

 

 

 

 

*

 

 

 

 

 

 

 

 

 

 

)

 

 

 

 

 

 

LDL)

 

 

*

 

 

 

 

 

 

 

 

©

*

 

 

 

 

 

 

 

 

 

 

 

 

 

 

)

 

 

 

PHP.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

jbj*chc*

 

 

 

 

 

 

 

 

*

 

 

 

 

 

 

 

 

©

©

 

 

LDL*

 

 

 

CASE_LOWER (integer)

 

 

 

 

 

 

 

 

?=OAZHKSAN

 

 

[l[sZ]b[ha_Ze_sZ][m_%&

 

 

 

 

 

©

 

*

 

 

[l[sZ]b[ha_Ze_sZ][m_%&

 

 

 

*

 

 

 

 

 

 

 

 

CASE_UPPER (integer)

 

 

 

 

 

 

 

 

?=OAZQLLAN

 

 

[l[sZ]b[ha_Ze_sZ][m_%&

 

 

 

 

 

 

 

*

 

 

 

 

 

 

is_array

 

 

 

 

 

 

 

 

 

 

(PHP 3, PHP 4, PHP 5)

 

 

 

 

 

 

 

 

is_array -

 

,

.

 

 

 

 

 

 

 

bool is_array (mixed var)

 

 

 

 

 

 

 

 

 

TRUE,

var

array, FALSE -

 

 

.

 

 

 

explode

 

 

 

 

 

 

 

 

 

(PHP 3, PHP 4, PHP 5) explode --

array explode ( string separator, string string [, int limit] )

34

 

,

 

string

 

separator

.

 

limit

,

 

 

limit

,

 

 

 

string.

 

 

 

 

separator - ©

(""), explode()

FALSE.

separator

 

string, explode()

,

 

string.

 

 

 

 

,

implode()

©

 

 

-

,

explode()

. separator ©

 

 

,

string -

.

implode

 

 

 

 

 

 

 

(PHP 3, PHP 4, PHP 5)

 

 

 

 

 

 

implode --

'

 

 

 

 

 

 

string implode ( string glue, array pieces )

 

 

 

 

 

 

)

$

 

 

 

 

jc_]_m)

afo_ ©

*

 

 

 

 

 

©

6

)

cgjfi^_%&

©

 

 

-

)

 

_rjfi^_%&

 

 

 

*

©

6

0*/*,

afo_

 

cgjfi^_%&

$

 

©

%$&*

 

 

 

 

 

©

 

*

 

 

 

 

 

©

6

 

 

 

 

*

 

split

 

 

 

 

 

 

 

(PHP 3, PHP 4, PHP 5)

 

 

 

 

 

 

split -

 

 

 

©

*

 

 

array split (string pattern, string string [, int limit])

 

: preg_split(),

 

Perl -

 

 

,

 

 

split().

 

 

 

 

 

 

 

 

 

 

,

©

 

 

string

 

 

 

© ,

 

 

pattern

©

.

limit

,

 

 

 

limit

 

 

 

,

 

string.

 

 

, split()

 

FALSE.

 

 

 

 

 

 

)

 

 

 

+_n]+j[mmq^6

 

 

 

 

1. split() list($user,$pass,$uid,$gid,$extra)= split (":", $passwd_line, 5);

 

 

 

:

n

©

 

pattern,

 

 

n+1

.

)

©

j[n_lh

)

 

 

*

)

©

 

)

mnlcha

© *

 

 

 

 

 

 

 

)

©

 

©

)

 

6

 

 

.*mjfcn%&!^[n_9 ,0+/,+53/7+

©

©

mf[mb)^in

bsjb_h

 

list ($month, $day, $year) = split ('[/. -]'date);

 

 

 

 

 

echo "Month: $month; Day: $day; Year: $year<br>\n";

 

 

 

 

 

)

j[n_lh

 

*

 

 

 

 

 

)

 

 

 

©

 

)

 

 

_rjfi^_%&)

 

 

©

 

 

*

 

 

 

preg_split

(PHP 3 >= 3.0.9, PHP 4, PHP 5) preg_split --

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

,

subject,

© ,

pattern.

 

 

35

,

limit

,

 

, ©limit

.

fcgcn)

)- )

 

© )

©

 

 

f[am*

 

 

 

 

f[am ©

 

 

 

%$

 

$v$&6

 

 

 

 

 

PREG_SPLIT_NO_EMPTY

 

 

 

 

)

 

)

jl_aZmjfcn%&

©

*

PREG_SPLIT_DELIM_CAPTURE

 

 

 

)

 

)

© )

©

)

©

 

 

*

 

LDL0*,*1*

PREG_SPLIT_OFFSET_CAPTURE

 

 

 

)

 

)

©

)

 

 

*

$ )

 

 

6 ©

©

 

)

 

 

)

-*

 

*jl_aZmjfcn%&

6

 

8;jbj

+

 

 

 

)

+

)\r, \t, \h \f

 

 

$keywords = preg_split("/[\s,]+/", "hypertext language, programming");

?>

 

 

 

 

 

.*

 

 

8;jbj

 

$str = 'string';

 

 

 

 

$chars = preg_split('//'str, - 1, PREG_SPLIT_NO_EMPTY);

 

print_r($chars);

 

 

 

?>

 

 

 

 

 

3.

 

 

©

<?php

$str = 'hypertext language programming';

 

$chars = preg_split('/ /'str, - 1, PREG_SPLIT_OFFSET_CAPTURE);

print_r($chars);

 

 

 

?>

 

 

 

 

 

 

: Array

 

 

(

[0] => Array

 

 

 

(

[0] => hypertext

 

 

 

 

[1] => 0

)

 

 

 

 

[1] => Array

 

 

 

( [0] => language

 

 

 

 

[1] => 10

)

 

 

 

 

[2] => Array

 

 

 

 

(

[0] => programming

 

 

 

[1] => 19

))

 

 

 

join

 

 

 

 

(PHP 3, PHP 4, PHP 5)

 

 

 

join --

 

implode()

 

 

 

 

 

 

implode().

 

 

 

Pcck

e

k co

c

*

 

%

 

&

©

 

;

 

 

 

 

<?php

//1

$" = 1 piece2 piece3 piece4 piece5 piece6";

!9 % )! &7

!W,X7+jc_]_

36

!WX7+jc_]_.

+.

! 9 ii6'6,./6,,,6+

+ii6+

+)

7

 

 

%!

 

)! )!oc^)!

)!a_]im)! )!

&9

%6)! &7

 

!7+ii

 

 

 

 

 

 

!7+'

 

 

 

 

 

 

?>

 

 

 

 

 

 

 

.*

 

%

 

&

 

 

©

;

 

 

 

 

 

 

 

<?php

 

 

 

 

 

 

 

![l[s9

%$f[mnh[g_$)

$

$)$

$&7

 

 

!

9

Z

%))!

&7

 

 

 

 

Z

!7+f[mnh[g_)

 

)

 

 

?>

 

 

 

 

 

 

 

 

 

 

 

 

e

 

 

1.

 

Z[l[s*

 

 

 

 

 

2.

 

 

*

 

 

 

 

3.

 

 

*

 

 

 

 

4.

 

*

 

 

 

 

5.

 

 

*

 

 

 

 

37

 

 

Po ek o

-

c k cc k

 

 

 

 

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

e o

 

 

 

 

 

 

 

 

©

*

 

LDL

)

 

 

 

 

 

*

 

 

/ 6

 

 

 

 

 

 

*

 

 

 

 

 

 

 

*

 

 

 

 

 

 

 

*

 

 

 

 

 

 

E*

 

 

 

 

 

 

 

)

 

 

 

 

LDL

 

ij_h%&*

$

 

$

 

©

*

 

 

$fp = fopen('counter.txt ', 'r');

 

 

 

 

 

 

 

LDL

 

 

 

©

6

 

r -

 

*

 

 

 

 

 

r+ -

 

 

 

*

 

 

 

w -

©

*

 

 

 

©

)

*

 

 

 

 

 

 

 

w+ -

l()

 

 

 

 

)

*

a -

 

©

)

 

©

 

%

&*

 

 

 

 

 

 

a+ -

©

 

 

 

 

©

 

%

&*

 

*

 

 

 

 

6

-

©

 

 

 

$

6 n*

)

 

©

 

 

 

+ *

© n)

©

 

)

 

 

 

 

*

 

 

 

 

6

 

 

 

<?php

 

 

 

 

 

 

 

+

©

 

 

 

 

 

 

$fp = fopen('counter.txt ', 'r'); //

©

 

 

 

 

 

$fp = fopen('counter.txt ', 'rt'); //

©

 

 

 

 

!j9 ij_h%bnj6+qqq*s[h^_r*lo )l&7+

 

 

DPPL $

 

!j9 ij_h%nj6+om_l6j[mmqil^<_r[gjf_*lo )$q$&7+

BPL $

?>

 

 

 

 

 

 

 

E*

 

 

 

 

 

 

 

 

 

LDL

©

 

 

qlcn_%&*

. $

 

$

*

$

 

 

©6

<?php

 

!j9 ij_h%]iohn_l*nrn)[&7+

©

38

!gsn_rn9

 

\r\h7+

 

 

$test = fwrite($fp, $mytext); //

 

 

 

 

if ($test) echo '

 

.';

 

 

_fm__]bi$

*$7

 

 

 

]fim_%!j&7+

 

 

 

 

?>

 

 

 

 

 

 

 

 

 

a_nm%&*

.

$

6

 

 

 

 

<?php

 

 

 

 

 

!j9 ij_h%]iohn_l*nrn)l&7+

 

 

©

 

if ($fp)

 

 

 

 

 

{

 

 

 

 

 

while (!feof($fp))

 

 

 

 

{

 

 

 

 

 

$mytext = fgets($fp, 999);

 

 

 

 

echo $mytext".<br />";

 

 

 

 

} }

 

 

 

 

 

else echo "

";

 

 

 

fclose($fp); ?>

 

 

 

 

 

:

999

 

,

 

,

©

(EOF).

 

 

 

,

 

,

readfile(),

1

'

.

,

©

,

 

:

 

 

 

 

 

<?php

 

 

 

 

 

echoreadfile("counter.txt");

 

 

 

 

?>

 

 

 

 

 

©

©

fpassthru()

1 '

.

 

 

 

©

*

 

 

%

 

 

&*

 

<?php

 

 

 

 

 

!j9 ij_h%]iohn_l*nrn)l&7+

 

 

©

 

if ($fp) echo fpassthru($fp);

 

 

 

 

_fm__]bi

7

 

 

 

?>

 

 

 

 

 

©

)

 

 

*

©

 

cf_%&*

 

 

) ©

©

 

*

 

 

 

 

 

6

 

cf_%&

%ch[ls- m[_&)

 

 

 

 

)

)

 

%AKB&)

 

 

 

*

 

<?php

 

 

 

 

 

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

 

 

$file_array

 

//

 

 

 

 

 

+

 

 

 

 

 

//

 

 

 

 

 

?>

 

 

 

 

 

 

)

 

 

*

 

©

a_n]%&*

 

 

*

 

 

-

 

 

*

 

<?php

 

 

 

 

 

!j9 ij_h%]iohn_l*nrn)l&7+

 

 

©

 

if ($fp)

39

{

 

 

 

 

while(!feof($fp))

 

 

 

{

 

 

 

 

$char = fgetc($fp);

 

 

 

if ($char == '

') $i = $i + 1;//

"

"

 

}

 

 

 

 

_]bi$

]

6$*!c7

 

 

}

 

 

 

 

_fm__]bi

 

7

 

 

?>

 

 

 

 

E*

 

 

 

 

 

 

 

]fim_%&)

$

*

 

 

 

 

<?php

 

 

 

 

$fp = fopen("counter.txt", "r");

 

 

 

if ($fp)

 

 

 

 

{

 

 

 

 

echo '

';

 

 

 

fclose($fp); //

 

 

 

 

} ?>

 

 

 

 

 

Pcec

ek c co

k

 

1.

 

 

6

 

&

 

 

*

 

cf_Z_rcmnm%&*

 

 

 

 

<?php

 

 

 

 

gscf_%]iohn_l*nrn&7+

 

gscf_)

$

oh]ncihgscf_%!h[g_&+

 

 

 

{

 

 

 

 

if (file_exists($name)) echo '

';

 

 

else echo "

";

 

 

 

}

 

 

 

 

?>

 

 

 

 

6

cf_Z_rcmnm

-

*

 

)

 

)

)

*

 

 

 

 

.&

 

 

cf_mct_%&

 

<?php

 

 

 

 

myfile("counter.txt");

 

 

 

oh]ncihgscf_%!h[g_&+

 

 

 

{

 

 

 

 

if (file_exists($name)) echo "

: ".filesize($name).' ';

 

else echo "

";

 

 

 

}

 

 

 

 

?>

 

 

 

 

/&

 

 

ngjcf_%&

 

<?php

 

 

 

 

$myfile = tmpfile();

 

 

 

 

qlcn_%!gscf_)

 

 

*&7+

 

m__e%!gscf_),&7+

 

©

 

 

echo fre[^%!gscf_),.0&7+

?>

40