문자열 zip_entry_name($zip_entry)매개변수:이 함수는 하나의 매개변수 $zip_entry, 필수입니다. zip 레코드 리소스를 지정하는 데 사용됩니다.반환 값:성공하면 zip 아카이브 레코드의 이름을 반환합니다.오류 및 예외:
- Zip_entry_name()은 zip 아카이브 이름을 반환합니다. 성공할 경우에만, 그렇지 않으면 PHP 경고를 반환합니다.
- zip_entry_name() 함수는 압축 파일이 유효하지 않은 경우 ER_OPEN을 반환합니다.
- zip_entry_name() 함수는 다음과 같은 경우 ER_NOZIP 오류를 반환합니다. zip 아카이브가 비어 있습니다.
content.xlsx
// zip 파일 열기
$zip_handle
= zip_open (
" C: /xampp/htdocs/article.zip "
);
// zip 아카이브 읽기
$ zip_entry
= zip_read (
$zip_handle
);
// 우편번호 읽기 아카이브 이름
$file
= zip_entry_name (
$zip_entry
);
echo
(
"파일 이름:"
.
$file
);
// zip 아카이브 닫기
zip_close (
$zip_handle
);
?>
출력:파일 이름: article / content.xlsx
프로그램 2: zip 파일 기사를 가정합니다. zip에는 다음 파일과 디렉토리가 포함되어 있습니다.
디렉토리: img - engineerforengineer.png
- engineerforengineer1.png
content.xlsx< br>gfg.pdf
image.jpeg <코드>
// zip 파일 열기
$zip_handle
= zip_open (
"C: /xampp/htdocs/article.zip"
);
if
(
is_resource
(
$zip_handle
))
{
동안
(
$zip_entry
= zip_read (
$zip_handle
))
{
$file
= zip_entry_name (
$zip_entry
);
// zip 아카이브 항목의 파일 이름 확인
$file_name
= zip_entry_name (
$zip_entry
);
echo
(
"파일 이름:"
.
$file_name
.
" < br > "
);
}
// zip 아카이브 닫기
zip_close (
$zip_handle
);
}
else
echo
(
"Zip 아카이브를 읽을 수 없습니다. . "
);
?>
출력:파일 이름: 기사 / content.xlsx 파일 이름: article / gfg.pdf 파일 이름: article / image.jpeg 파일 이름: article / img / 파일 이름: article / img / engineerforengineer.png 파일 이름: article / img / engineerforengineer1.png관련 기사:
- PHP | Zip_read() 함수
- PHP | Zip_close() 함수
- PHP | Zip_entry_close() 함수
- PHP | Zip_entry_compressedsize() 함수