sonderzeichen konvertiern u. txt file schreiben

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • sonderzeichen konvertiern u. txt file schreiben

    ich nicht programmierer hab 2 schnipsel die ich nicht zusammen bringen kann.

    der eine konvertiert ein paar sonderzeichen so,

    function format_output($output) {

    $output = str_replace('!', '%21', $output);
    $output = str_replace('&', '%26', $output);
    return nl2br($output);
    }

    function print_output($output) {

    echo format_output($output);
    }

    bekommt die variabeln so;

    <textarea name="content" cols="80" rows="7" wrap=off><?
    if (isset($content)) echo htmlSpecialChars(stripslashes($content));
    ?></textarea>

    wird dann so ausgegeben;

    <? if (isset($content)) { ?>
    <? print_output($content) ?>
    <? } ?>

    und wird dann hier gebraucht um das file zu schreiben;

    <?php

    $datei = fopen("$datei.txt","w");
    fwrite($datei, "$content ");
    fclose($datei);

    ?>


    statt hier $content muss das print_output
    irgendwie in das fwrite rein. mein syntax ist wie mein deutsch, holprig.

    kann jemand mir sagen was hier los ist, i rüpf mir die letzten haare aus!

    danke

  • #2
    $content=print_output($content);

    $datei = fopen("$datei.txt","w");
    fwrite($datei, "$content ");
    fclose($datei);


    das sollte gehen, aber ohne garantie
    -=Es gibt Leute, die können Ihren Stammbaum bis zu denen zurückverfolgen, die noch darauf saßen=-

    Kommentar


    • #3
      wäre logisch, geht aber nicht, der $content wird einfach in die seite dargestellt, aber nicht in der fwrite ausgegeben.

      Kommentar


      • #4
        Sind das verschiedene von einander unabhängige Skripte?
        Falls es ein Skript ist poste es bitte hier einmal.

        [php ]
        Setze das Skript zwischen die beiden Dinger da (ohne Blank), damit das ganze strukturiert ausgegeben wird.
        [/php ]


        Womit ist eigentlich die Variable $datei belegt?
        (siehe $datei.txt)

        $datei = fopen("$datei.txt","w");
        fwrite($datei, "$content ");
        fclose($datei);
        Zuletzt geändert von hand; 25.07.2002, 16:07.

        Kommentar


        • #5
          es sind 3 seiten

          das ouputlib.php,

          function format_output($output) {

          $output = str_replace('!', '%21', $output);
          $output = str_replace('&', '%26', $output);
          $output = str_replace('+', '%2B', $output);
          $output = str_replace('?', '%3F', $output);
          $output = str_replace('"', '%22', $output);
          $output = str_replace('.', '%2E', $output);
          $output = str_replace(',', '%2C', $output);
          $output = str_replace(' ', '%20', $output);
          return nl2br($output);
          }

          function print_output($output) {

          echo format_output($output);
          }


          wird included und diese form;

          <form method="POST" action="preview.php">
          <input type="hidden" value="output=" name="output">
          <input type="hidden" value="text" name="datei">
          <textarea name="content" cols="80" rows="2" wrap=off>
          <?if (isset($content)); echo htmlSpecialChars(stripslashes($content));
          ?></textarea>
          <input type="submit" value="Preview">
          </form>

          wird dann hier weitergereicht

          <?php

          $datei = fopen("$datei.txt","w");
          fwrite($datei, "$output$content");
          fclose($datei);
          ?>

          ohne konvertierung kein problem, und wenn ich eine hidden field mit
          <input type="hidden" name="flash" value="<? $content=print_output($content); ?>">
          habe, wird es auch korrekt dargestellt

          Kommentar

          Lädt...
          X