.


:




:

































 

 

 

 


6 -

:

, , , , . , .

. , , .

PHP , . , .

Unix \n, Windows \r\n. , . , , \n, .

int fopen(string $filename, string $mode, bool $use_include_path=false)

$filename $mode . "", , , fopen() false. $use_include_path PHP , , , , include require. . $mode :

mode
'r' . , . , . . .
'r+' . . r, , false.
'w' ; . - .
'w+' r+, , . , . , .
'a' , . , - . .
'a+' , , . a , , . , - (, ), ,

r, w, a, r+, w+ a+ b t. b ( ), /. t, , . . .

int tmpfile()

. , . , , . , , .

int fclose(int $fp)

. , false . PHP . .

string fread(int $f, int $numbytes)

$f $numbytes . ( ). $numbytes , (, ), , .

int fwrite(int $f, string $st)

$f $st. fread(), . ( t ) \n , .

string fgets(int $f, int $length)

, \n. . $length-1 , $length-1 . , "" . ( ) File().

int fputs(int $f, string $st)

fwrite(). , fread/fwrite , fputs/fgets ( ).

int feof(int $f)

true, .

int fseek(int $f, in $offset, int $whence = SEEK_SET)

$offset ( , , $whence). $whence, , , $offset. PHP , , , 0, 1 2:

  • SEEK_SET
  • SEEK_CUR
  • SEEK_END

$offset ( SEEK_END ). , 0, -1.

int ftell(int $f)

.

int filesize(string $filename)

.

bool file_exists(string $filename)

true, $filename .

bool is_file(string $filename)

true, $filename .

bool is_dir(string $filename)

true, $filename .

string basename(string $path)

$path.

string dirname(string $path)

, $path.

bool copy(string $src, string $dst)

$src $dst. , $dst , . true, , false.

bool rename(string $oldname, string $newname)

( , ) $oldname $newname. $newname , , false.

bool unlink(string $filename)

$filename. false, true.

array file(string $filename)

$filename , . , fopen() . , , , . , rtrim().

1.

: .

:

:

a+, :

  • ,

, .

.

  • IP-
  • ( , , .. )

, \n. , . \n , \, n. , , . fclose().

:

 

1 2 .

. .

: .

:

, , html-. , , enctype form multipart/form-data, input file.

$_FILES.

$_FILES :

$_FILES['myfile']['name'] - , .

$_FILES['myfile']['type'] - mime- , .

$_FILES['myfile']['size'] - .

$_FILES['myfile']['tmp_name'] - , .

$_FILES['myfile']['error'] - , .

'myfile' - , . , . (name, type . .) .

PHP $_FILES['myfile']['error'] :

  • 0 - ,
  • 1 - , upload_max_filesize php.ini
  • 2 - , MAX_FILE_SIZE html
  • 3 -
  • 4 -

, upload_tmp_dir php.ini. move_uploaded_file().

move_uploaded_file() :

bool move_uploaded_file (__, _)

, , __, HTTP POST. , , _ ( , ).

__ , , move_uploaded_file() FALSE. , - . . , _, , move_uploaded_file() .

:

bool mkdir(string $name, int $perms)

$name $perms. , . $perms 0770 ( PHP , , ). 0770 " , ". true, false.

bool rmdir(string $name)

$name. true, false.

bool chdir(string $path)

. , false. $path , .

string getcwd()

, "" (/). , "" false.

int opendir(string $path)

$path . readdir() . false, .

string readdir(int $handle)

$handle . : . ( ) .. ( ). . false.

void closedir(int $handle)

$handle. .

void rewinddir(int $handle)

"" . readdir(), .

 

6

6-1

. :

. ( ) .

:

6-2

a) .

b) .

6-3

.

:

  1. ( );
  2. gallery;
  3. ;
  4. ( 200 );
  5. , ;
  6. ( );
  7. ( ).

 

 

6

  1. ?
  2. /?
  3. , ?
  4. ( )?

 

 



<== | ==>
1..3 , | : - 50 .
:


: 2016-12-29; !; : 703 |


:

:

, .
==> ...

1528 - | 1299 -


© 2015-2024 lektsii.org - -

: 0.042 .