mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-27 22:38:55 +00:00
114 lines
3 KiB
XML
114 lines
3 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="pharfileinfo.construct" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>PharFileInfo::__construct</refname>
|
|
<refpurpose>Construct a Phar entry object</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<constructorsynopsis>
|
|
<modifier>public</modifier> <methodname>PharFileInfo::__construct</methodname>
|
|
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
|
|
</constructorsynopsis>
|
|
|
|
<para>
|
|
This should not be called directly. Instead, a PharFileInfo object
|
|
is initialized by calling <function>Phar::offsetGet</function>
|
|
through array access.
|
|
</para>
|
|
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>filename</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The full url to retrieve a file. If you wish to retrieve the information
|
|
for the file <literal>my/file.php</literal> from the phar <literal>boo.phar</literal>,
|
|
the entry should be <literal>phar://boo.phar/my/file.php</literal>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<para>
|
|
Throws <classname>BadMethodCallException</classname> if
|
|
<link linkend="object.construct">__construct()</link> is called twice.
|
|
Throws <classname>UnexpectedValueException</classname> if
|
|
the phar URL requested is malformed, the requested
|
|
phar cannot be opened, or the file can't be found within the phar.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>A <function>PharFileInfo::__construct</function> example</title>
|
|
<para>
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
try {
|
|
$p = new Phar('/path/to/my.phar', 0, 'my.phar');
|
|
$p['testfile.txt'] = "hi\nthere\ndude";
|
|
$file = $p['testfile.txt'];
|
|
foreach ($file as $line => $text) {
|
|
echo "line number $line: $text";
|
|
}
|
|
// this also works
|
|
$file = new PharFileInfo('phar:///path/to/my.phar/testfile.txt');
|
|
foreach ($file as $line => $text) {
|
|
echo "line number $line: $text";
|
|
}
|
|
} catch (Exception $e) {
|
|
echo 'Phar operations failed: ', $e;
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
line number 1: hi
|
|
line number 2: there
|
|
line number 3: dude
|
|
line number 1: hi
|
|
line number 2: there
|
|
line number 3: dude
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|