Bash, Shell, PHP, Python, Perl, CGI
-
Anonymous
-
Post
by Anonymous »
Hi,
ich habe ein problem, und zwar will ich mit PHP die existenz einer Dateu überprüfen. Dazu habe ich folgenden Code:
Code: Select all
$filename = "status.dat;
$datafile = @fopen($filename , "r");
if ($datafile <=0)
{
print "nicht vorhanden";
}
else
{
$content = fgets($datafile, "12");
fclose($datafile);
}
Doch statt der gewünschten Ausgabe bekomme ich
Parse error: parse error in /home/admin/hostfire/include/status.php on line 3
zurück. Wie kann ich das eleganz überprüfen ohne die Fehlermeldung???
Gruß,
Daniel
-
arty
- Userprojekt

- Posts: 729
- Joined: 2002-06-12 10:11
-
Contact:
-
Post
by arty »
Code: Select all
$filename = "status.dat;
$datafile = @fopen($filename , "r");
if (isset($datafile))
{
print "nicht vorhanden";
}
else
{
$content = fgets($datafile, "12");
fclose($datafile);
}
bye
arty
-
Anonymous
-
Post
by Anonymous »
Der macht den Fehler ja eine Zeile vorher, bis zu dem isset kommt der ja gar nicht.
Der Fehler kommt bei
$datafile = @fopen($filename , "r");
Daniel
-
alrad
- Posts: 90
- Joined: 2003-04-27 10:15
-
Post
by alrad »
Hallo DMKlein,
schau dir mal die erste Zeile an. Fehlt da nicht etwas?
Gruß
Albert
-
Anonymous
-
Post
by Anonymous »
Ich weiß nicht was du meinst....
Daniel
-
alrad
- Posts: 90
- Joined: 2003-04-27 10:15
-
Post
by alrad »
Ich meine, die erste Zeile sollte wie folgt aussehen:
$filename = "status.dat";
Da fehlt ein ".
Gruß
Albert
-
niklas_
- Posts: 122
- Joined: 2003-08-13 20:46
-
Post
by niklas_ »
Warum so umständlich? Es gibt eine Funktion die das erledigt:
Code: Select all
<?PHP
$datei = "datei.php";
if(file_exists($datei))
{
echo "vorhanden";
}
else
{
echo "nicht vorhanden";
}