aktuelle.kurse/m133/Weiteres/Modul_Unterlagen_133_VO/08 Uebungen/03 PHP Grundlagen/PHP_Referenz/funktionsreferenz/dateisystem_funktionen/fopen.html
Harald G. Mueller a2dc35ce82 muh
2022-02-24 09:37:43 +01:00

209 lines
11 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>fopen</title>
<link rel="stylesheet" type="text/css" href="../../src/self.css">
<meta name="description" content="&Ouml;ffnet eine Datei oder URL">
<meta name="keywords" content="SELFPHP, PHP, Dateisystem-Funktionen, fopen">
<meta name="author" content="Damir Enseleit, mail@selfphp.info">
<meta name="DC.Contributer" content="Matthias Hupp, m.hupp@selfphp3.de">
<meta name="DC.Publisher" content="Damir Enseleit, mail@selfphp.info">
<meta name="DC.Date" content="2001-08-13T12:18+01:00">
<meta name="DC.Identifier" content="http://www.selfphp3.de/funktionsreferenz/dateisystem_funktionen/fopen.html">
<meta name="DC.Language" content="de">
<meta name="DC.Rights" content="../../editorial/index.html">
<meta name="SELF.Firstdate" content="2001-08-13T12:18+01:00">
<meta name="SELF.Version" content="1">
<meta name="SELF.Pagetype" content="Information">
<meta name="SELF.Path" content="SELFPHP == ../../index.php // Funktionsreferenz == ../index.php // Dateisystem-Funktionen == index.html">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#AA5522" vlink="#772200" alink="#000000">
<table cellpadding="4" cellspacing="0" border="0" width="100%">
<tr>
<td bgcolor="#FFEEDD" class="nav"><a class="an" name="top"><img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von"></a> <a href="../../index.html"><b>SELFPHP</b></a>/<a href="../../navigation/index.html">Navigationshilfen</a> <img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von"> <a href="../index.html"><b>Funktionsreferenz</b></a> <img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von"> <a href="index.html"><b>Dateisystem-Funktionen</b></a></td>
</tr>
</table>
<table cellpadding="4" cellspacing="0" border="0" width="100%">
<tr>
<td bgcolor="#EEEEEE" class="doc" width="110"><img src="../../src/logo.gif" width="106" height="109" border="0" alt="SEL.html"></td>
<td bgcolor="#EEEEEE" class="doc" valign="bottom" width="100%">
<h2>fopen</h2></td>
</tr>
<tr>
<td bgcolor="#EEEEEE" class="doc" valign="top" align="center"> <img src="../../src/dokx.gif" width="30" height="20" vspace="6" border="0" alt="Informationsseite">
</td>
<td bgcolor="#FFFFFF" valign="top" nowrap colspan="2">
<p> <img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#befehl"><b>Befehl</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#version"><b>Version</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#beschreibung"><b>Beschreibung</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#beispiel"><b>Beispiel</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#ausgabe"><b>Ausgabe</b></a><br>
</p>
</td>
</tr>
<tr>
<td colspan=3 bgcolor="#EEEEEE" class="doc"><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;</td>
</tr>
</table>
<h2 class="Sh2"><a class="an" name="befehl">Befehl</a></h2>
<table width="100%" cellpadding=10><tr>
<td class="xmpcode" bgcolor="#E4EEFF">int <b>fopen</b>(string filename, string
mode [, int use_include_path])
<p></p>
</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="version">Version</a></h2>
<table width="100%" cellpadding=10 height="32">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF" height="20">
<p> PHP 3, PHP 4 &gt;= 4.0b1</p>
</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="beschreibung">Beschreibung</a></h2>
<table width="100%" cellpadding=10 height="232">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF" height="57">
<p>Mit fopen() kann man eine Datei (filename) &ouml;ffnen. Folgende<br>
Verbindungsm&ouml;glichkeiten gibt es:<br>
&quot;http://&quot; - &Ouml;ffnen per http<br>
&quot;ftp://&quot; - &Ouml;ffnen per ftp<br>
&quot;php://stdin&quot; - &Ouml;ffnen per stdio stream <br>
&quot;php://stdout&quot; - &Ouml;ffnen per stdio stream<br>
&quot;php://stderr&quot; - &Ouml;ffnen per stdio stream<br>
Alles andere - &Ouml;ffnen vom lokalen Dateisystem<br>
Der Parameter mode legt fest, auf welche Weise und f&uuml;r welche Zugriffsarten
die<br>
Datei ge&ouml;ffnet wird. Folgende Werte gibt es:<br>
a - &Ouml;ffnet die angegebene Datei nur zum Schreiben und positioniert
den<br>
Dateizeiger auf das Ende der Datei. Sollte die angegebene Datei nicht
existieren,<br>
so wird versucht sie anzulegen. <br>
a+ - &Ouml;ffnet die angegebene Datei zum Lesen und Schreiben und positioniert
den<br>
Dateizeiger auf das Ende der Datei. Sollte die angegebene Datei nicht
existieren,<br>
so wird versucht sie anzulegen. <br>
r - &Ouml;ffnet die angegebene Datei zum Lesen und positioniert den Dateizeiger
auf<br>
den Anfang der Datei.<br>
r+ - &Ouml;ffnet die angegebene Datei zum Lesen und Schreiben und positioniert
den<br>
Dateizeiger auf den Anfang der Datei.<br>
w - &Ouml;ffnet die angegebene Datei zum Schreiben und positioniert den
Dateizeiger<br>
auf den Anfang der Datei. Die L&auml;nge der Datei wird auf 0 Byte gesetzt.
Sollte die<br>
angegebene Datei nicht existieren, so wird versucht sie anzulegen. <br>
w+ - &Ouml;ffnet die angegebene Datei zum Lesen und Schreiben und positioniert
den<br>
Dateizeiger auf den Anfang der Datei. Sollte die angegebene Datei nicht<br>
existieren, so wird versucht sie anzulegen. </p>
<p>F&uuml;r die Bearbeitung von Bin&auml;rdateien k&ouml;nnen Sie an jede
dieser<br>
Modusdefinitionen ein &quot;b&quot; anh&auml;ngen. <br>
Wird der optionale Parameter use_include_path auf 1 gesetzt, so wird auch<br>
innerhalb des Include-Pfads (wird in der php.ini bestimmt) nach der Datei<br>
gesucht. </p>
<p>Im Erfolgsfall gibt die Funktion einen Dateizeiger zur&uuml;ck. Sollte
das &Ouml;ffnen der<br>
Datei scheitern, so wird false zur&uuml;ckgeliefert.</p>
<p>Siehe auch:</p>
<ul>
<li><a href="fclose.html">fclose()</a></li>
<li>fsockopen()</li>
<li><a href="popen.html">popen()</a><br>
</li>
</ul>
</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="beispiel">Beispiel</a></h2>
<table width="100%" cellpadding=10 height="62">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF">
<pre>&lt;?PHP<br>$fp = fopen(&quot;/www/users/php/counter.txt&quot;,&quot;r&quot;); // Absoluter Pfad<br>$fp = fopen(&quot;counter.txt&quot;,&quot;r&quot;); // Relativ Pfad<br>$fp = fopen(&quot;/www/users/php/selfphp.gif&quot;,&quot;wb&quot;);<br>$fp = fopen(&quot;http://www.selfphp3.de/&quot;,&quot;r&quot;);<br>$fp = fopen(&quot;ftp://user:password@selfphp3.de/&quot;,&quot;r&quot;);<br>$fp = fopen(&quot;d:/daten/statistik.csv&quot;,&quot;a&quot;);<br>?&gt;</pre>
</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="ausgabe">Ausgabe</a></h2>
<table width="100%" cellpadding=10 height="45">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF" height="57">
<p>// Keine Ausgabe<br>
// Es werden die M&ouml;glichkeiten vorgestellt</p>
</td>
</tr></table>
<p>&nbsp;</p>
<table cellpadding="4" cellspacing="0" border="0" width="100%">
<tr><td colspan=2 bgcolor="#EEEEEE" class="doc">
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a>
</td></tr>
<tr>
<td bgcolor="#EEEEEE" class="doc" align="right" width="110">weiter:<a href="fpassthru.html"><img src="../../src/next.gif" width="10" height="10" border="0" hspace="10" alt="weiter"></a></td>
<td bgcolor="#FFFFFF"><img src="../../src/dok.gif" width="15" height="10" border="0" alt="Seite">
<a href="fpassthru.html"><b>fpassthru</b></a> </td>
</tr>
<tr>
<td bgcolor="#EEEEEE" class="doc" align="right" width="110">zur&uuml;ck:<a href="flock.html"><img src="../../src/prev.gif" width="10" height="10" border="0" hspace="10" alt="zur&uuml;ck"></a></td>
<td bgcolor="#FFFFFF" width="100%"><img src="../../src/dok.gif" width="15" height="10" border="0" alt="Seite">
<a href="flock.html"><b>flock</b></a> </td>
</tr>
<tr><td colspan=2 bgcolor="#EEEEEE" class="doc">&#160;</td></tr>
</table><table cellpadding="4" cellspacing="0" border="0" width="100%">
<tr>
<td bgcolor="#FFEEDD" class="nav"><a class="an" name="bottom"><img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von"></a>
<a href="../../index.html"><b>SELFPHP</b></a>/<a href="../../navigation/index.html">Navigationshilfen</a> <img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von">
<a href="../index.html"><b>Funktionsreferenz</b></a> <img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von">
<a href="index.html"><b>Dateisystem-Funktionen</b></a></td>
</tr>
</table>
<p><a class="an" name="bottom">&copy; 2001, 2002, 2003</A> <img src="../../src/mail.gif" width="15" height="10" border="0" alt="E-Mail">&nbsp;<a href="mailto:mail@selfphp.info">Damir Enseleit, mail@selfphp.info</a></p>
</body>
</html>