mirror of
https://github.com/php/doc-ja.git
synced 2026-03-28 09:02:14 +01:00
117 lines
3.3 KiB
XML
117 lines
3.3 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: f03806fcd8fe03a0501bd40b6e3939ff6589a1d2 Maintainer: takagi Status: ready -->
|
|
<refentry xml:id="pharfileinfo.construct" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>PharFileInfo::__construct</refname>
|
|
<refpurpose>Phar エントリオブジェクトを作成する</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<constructorsynopsis role="PharFileInfo">
|
|
<modifier>public</modifier> <methodname>PharFileInfo::__construct</methodname>
|
|
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
|
|
</constructorsynopsis>
|
|
|
|
<para>
|
|
これは直接コールしてはいけません。PharFileInfo オブジェクトを作成するには、
|
|
配列へのアクセスを通じて <function>Phar::offsetGet</function>
|
|
をコールします。
|
|
</para>
|
|
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>filename</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
ファイルを取得するための完全な url。
|
|
ファイル <literal>my/file.php</literal>
|
|
の情報を phar <literal>boo.phar</literal> から取得したい場合は、
|
|
このエントリは <literal>phar://boo.phar/my/file.php</literal> となります。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<para>
|
|
<link linkend="object.construct">__construct()</link> が二度コールされた場合に
|
|
<classname>BadMethodCallException</classname>、
|
|
phar の URL がおかしかったり phar がオープンできなかったり、
|
|
あるいはファイルが phar 内で見つからなかった場合に
|
|
<classname>UnexpectedValueException</classname> がスローされます。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>PharFileInfo::__construct</function> の例</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: $text";
|
|
}
|
|
// これも動作します
|
|
$file = new PharFileInfo('phar:///path/to/my.phar/testfile.txt');
|
|
foreach ($file as $line => $text) {
|
|
echo "行番号 $line: $text";
|
|
}
|
|
} catch (Exception $e) {
|
|
echo 'Phar 操作に失敗しました: ', $e;
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
行番号 1: hi
|
|
行番号 2: there
|
|
行番号 3: dude
|
|
行番号 1: hi
|
|
行番号 2: there
|
|
行番号 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
|
|
-->
|