Einzelnen Beitrag anzeigen

Benutzerbild von H4ndy
H4ndy

Registriert seit: 28. Jun 2003
Ort: Chemnitz
515 Beiträge
 
Delphi XE3 Professional
 
#7

Re: [PHP]String an Anfang einer Textdatei

  Alt 28. Nov 2006, 16:40
Und prüfe am besten mal, ob dir fseek auch 0 (Erfolg) und nicht -1 (Fehlgeschlagen) zurückliefert.
Siehe auch http://de2.php.net/manual/de/function.fseek.php

Falls du kein PHP5 hast:
Code:
  if (!function_exists("file_put_contents")) {
    /**
     * For PHP4 backward compatibiliy.
     * Provides a simple version of the PHP5 function file_put_contents.
     * Provious content in the file $filename will be lost.
     * Returns the bytes which were successfully written.
     *
     * @param string $filename
     * @param string $text
     * @return integer
     */
    function file_put_contents($filename,$text){
      // provides file_put_contents for PHP < PHP5
      $fp = fopen($filename,"w+");
      $result = fwrite($fp,$text);
      fclose($fp);
      return $result;
    }
  }

  if (!function_exists("file_get_contents")) {
    /**
     * For PHP4 backward compatibiliy.
     * Provides a simple version of the PHP5 function file_get_contents.
     * Returns the content of the file as a string.
     *
     * @param string $filename
     * @return string
     */
    function file_get_contents($filename){
      if(($contents = file($filename))){
        $contents = implode('', $contents);
        return $contents;
      } else {
        return false;
      }
    }
  }
Manuel
  Mit Zitat antworten Zitat