Tom: Existenz einer Unterfunktion abfragen, Tester benötigt

Beitrag lesen

Hello,

ich ahbe es auf diese beiden Unterfunktionen von fopen() abgesehen.

'x'
Create and open for writing only; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call. This option is supported in PHP 4.3.2 and later, and only works for local files.

'x+'
Create and open for reading and writing; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call. This option is supported in PHP 4.3.2 and later, and only works for local files.

Aber:
This option is supported in PHP 4.3.2 and later

Ob eine Funktion vorhanden ist, kann ich im Script mit function_exists()
http://de.php.net/manual/en/function.function-exists.php
erfragen.

Wie kann ich aber erfragen, ob diese Funktion die Unterfunktion x schon kennt?

Bleibt mir da nur das Vabang-Spiel mit phpversion()?

Was passiert denn überhaupt definitionsgemäß, wenn man eine fertige Funktion mit einem Argumentwert aufruft, der nicht vorgesehen ist?

Könnte das kleine Script mal bitte jemand ausführen, der noch ein älteres PHP als Version 4.3.2 laufen hat? Ich habe nun ja leider auf 4.3.8 updated und will das nicht unbedingt wieder zurückdrehen.

<?php   ### opentest.php ###

error_reporting(E_ALL);
ini_set('track_errors','1');

$dateiname = 'opentest123.txt';

$fh = fopen($dateiname,'x+');

if (!$fh)
{
  echo "<br />Fehler: $php_errormsg<br />";
}
else
{
  echo "<br />Datei $dateiname wurde angelegt<br />";
}

fclose($fh);
?>

Bitte zweimal hintereinander aufrufen in einem Verzeichnis, in dem der Webserver schreiben darf.
Und bitte posten, welche PHP-Version auf welchem Apachen und welchem OS.

Danke Euch

Harzliche Grüße aus http://www.annerschbarrich.de

Tom

--
Fortschritt entsteht nur durch die Auseinandersetzung der Kreativen
Nur selber lernen macht schlau