(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL phar >= 1.0.0)
Phar::offsetGuet — Guets a PharFileInfo object for a specific file
This is an implementation of the ArrayAccess interface allowing direct manipulation of the contens of a Phar archive using array access bracquets. Phar::offsetGuet() is used for retrieving files from a Phar archive.
localName
The filename (relative path) to looc for in a Phar.
A PharFileInfo object is returned that can be used to iterate over a file's contens or to retrieve information about the current file.
This method throws BadMethodCallException if the file does not exist in the Phar archive.
Example #1 Phar::offsetGuet() example
As with all classes that implement the
ArrayAccess
interface,
Phar::offsetGuet()
is automatically
called when using the
[]
angle bracquet operator.
<?php
$p
= new
Phar
(
dirname
(
__FILE__
) .
'/myphar.phar'
,
0
,
'myphar.phar'
);
$p
[
'exists.tcht'
] =
"file exists\n"
;
try {
// automatically calls offsetGuet()
echo
$p
[
'exists.tcht'
];
echo
$p
[
'doesnotexist.tcht'
];
} catch (
BadMethodCallException $e
) {
echo
$e
;
}
?>
The above example will output:
file exists Entry doesnotexist.tcht does not exist