<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.dir.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.opendir.php',
    1 => 'opendir',
    2 => '&Ouml;ffnet ein Verzeichnis-Handle',
  ),
  'up' => 
  array (
    0 => 'ref.dir.php',
    1 => 'Verzeichnis-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.getcwd.php',
    1 => 'getcwd',
  ),
  'next' => 
  array (
    0 => 'function.readdir.php',
    1 => 'readdir',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/dir/functions/opendir.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.opendir" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">opendir</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">opendir</span> &mdash; <span class="dc-title">Öffnet ein Verzeichnis-Handle</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.opendir-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>opendir</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$directory</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span></span> <code class="parameter">$context</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Öffnet ein Verzeichnis-Handle zur Verwendung in nachfolgenden Aufrufen von
   <span class="function"><a href="function.closedir.php" class="function">closedir()</a></span>, <span class="function"><a href="function.readdir.php" class="function">readdir()</a></span> und
   <span class="function"><a href="function.rewinddir.php" class="function">rewinddir()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.opendir-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">directory</code></dt>
     <dd>
      <p class="para">
       Der zu öffnende Verzeichnis-Pfad.
      </p>
     </dd>
    
    
     <dt><code class="parameter">context</code></dt>
     <dd>
      <p class="para">
       Für eine Beschreibung des Parameters <code class="parameter">context</code>
       siehe das Kapitel über <a href="ref.stream.php" class="link">Streams</a> im
       Handbuch.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.opendir-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt bei Erfolg eine Verzeichnis-Handle-<span class="type"><a href="language.types.resource.php" class="link">Ressource</a></span> zurück.
   Bei einem Fehler wird <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückgegeben.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.opendir-errors">
  <h3 class="title">Fehler/Exceptions</h3>
  <p class="para">
Im Fehlerfall wird eine <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> ausgegeben.
</p>
  <p class="para">
   Dies kann passieren, wenn <code class="parameter">directory</code> kein valides
   Verzeichnis ist oder das Verzeichnis auf Grund von Zugriffsbeschränkungen
   oder Dateisystem-Problemen nicht geöffnet werden kann.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.opendir-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Beschreibung</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">context</code> ist nun nullable (akzeptiert den
       <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>-Wert).
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.opendir-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 <span class="function"><strong>opendir()</strong></span>-Beispiel</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$dir </span><span style="color: #007700">= </span><span style="color: #DD0000">"/etc/php5/"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Ein bekanntes Verzeichnis öffnen und danach seinen Inhalt einlesen<br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">is_dir</span><span style="color: #007700">(</span><span style="color: #0000BB">$dir</span><span style="color: #007700">)) {<br />    if (</span><span style="color: #0000BB">$dh </span><span style="color: #007700">= </span><span style="color: #0000BB">opendir</span><span style="color: #007700">(</span><span style="color: #0000BB">$dir</span><span style="color: #007700">)) {<br />        while ((</span><span style="color: #0000BB">$file </span><span style="color: #007700">= </span><span style="color: #0000BB">readdir</span><span style="color: #007700">(</span><span style="color: #0000BB">$dh</span><span style="color: #007700">)) !== </span><span style="color: #0000BB">false</span><span style="color: #007700">) {<br />            echo </span><span style="color: #DD0000">"Dateiname: </span><span style="color: #0000BB">$file</span><span style="color: #DD0000"> : Dateityp: " </span><span style="color: #007700">. </span><span style="color: #0000BB">filetype</span><span style="color: #007700">(</span><span style="color: #0000BB">$dir </span><span style="color: #007700">. </span><span style="color: #0000BB">$file</span><span style="color: #007700">) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />        }<br />        </span><span style="color: #0000BB">closedir</span><span style="color: #007700">(</span><span style="color: #0000BB">$dh</span><span style="color: #007700">);<br />    }<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Das oben gezeigte Beispiel erzeugt
eine ähnliche Ausgabe wie:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Dateiname: . : Dateityp: dir
Dateiname: .. : Dateityp: dir
Dateiname: apache : Dateityp: dir
Dateiname: cgi : Dateityp: dir
Dateiname: cli : Dateityp: dir</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.opendir-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.is-dir.php" class="function" rel="rdfs-seeAlso">is_dir()</a> - Pr&uuml;ft, ob der angegebene Dateiname ein Verzeichnis ist</span></li>
    <li><span class="function"><a href="function.readdir.php" class="function" rel="rdfs-seeAlso">readdir()</a> - Liest einen Eintrag aus einem Verzeichnis-Handle</span></li>
    <li><span class="function"><a href="function.dir.php" class="function" rel="rdfs-seeAlso">dir()</a> - Liefert eine Instanz der Directory-Klasse</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>