|
|
@@ -0,0 +1,47 @@
|
|
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
|
+<!-- Reviewed: no -->
|
|
|
+<!-- EN-Revision: 15715 -->
|
|
|
+<sect2 id="zend.filter.set.realpath">
|
|
|
+ <title>RealPath</title>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ このフィルタは与えられたリンクとパス名を解決して、正規化された絶対パス名を返します。
|
|
|
+ <filename>'/./'</filename>や<filename>'/../'</filename>への参照、
|
|
|
+ 及び、入力パスの余分な<filename>'/'</filename>記号は取り除かれます。
|
|
|
+ 結果のパスにはいかなるシンボリックリンクも無く、
|
|
|
+ <filename>'/./'</filename>や<filename>'/../'</filename>文字もありません。
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ たとえばファイルが存在しない場合、
|
|
|
+ <classname>Zend_Filter_RealPath</classname>は失敗すると<code>FALSE</code>を返します。
|
|
|
+ もし最後のパスのコンポーネントだけが存在しない場合、
|
|
|
+ BSDシステムでは<classname>Zend_Filter_RealPath</classname>は失敗しますが、
|
|
|
+ 他のシステムでは<constant>FALSE</constant>を返します。
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
+$filter = new Zend_Filter_RealPath();
|
|
|
+$path = '/www/var/path/../../mypath';
|
|
|
+$filtered = $filter->filter();
|
|
|
+
|
|
|
+// '/www/mypath' を返します。
|
|
|
+]]></programlisting>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ それらが存在しないとき、
|
|
|
+ たとえば、生成したいパスのために実際のパスを取得したいとき、
|
|
|
+ パスを得るためにしばしば役に立ちます。
|
|
|
+ 初期化で<constant>FALSE</constant>を渡すこともできますし、
|
|
|
+ それを設定するために<methodname>setExists()</methodname>を使うこともできます。
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
+$filter = new Zend_Filter_RealPath(false);
|
|
|
+$path = '/www/var/path/../../non/existing/path';
|
|
|
+$filtered = $filter->filter();
|
|
|
+
|
|
|
+// file_exists または realpath が false を返すときでも '/www/non/existing/path' を返します。
|
|
|
+]]></programlisting>
|
|
|
+
|
|
|
+</sect2>
|