online 1
gast (50)

/ Forum / Skripte(PHP,ASP,Perl...)

Skripte(PHP,ASP,Perl...)Skripte(PHP,ASP,Perl...)

Fragevon Valentin vom 08.02.2019, 10:53 Options

PHP -> php datei auslesen

Hallo,
wenn ich zum Beispiel mit

    code:
    $content = file_get_contents($file);
    echo $content;




eine PHP datei auslese...
dann klappt das wunderbar, allerdings wird der anfang nicht angezeig, d.H.
wenn ich eine .php datei auslese in der folgendes drinnsteht:

  
    <?php
    include "sys/common.php";
    $tpl->assign("welcome", $lang['welcome']);
    $tpl->printToScreen();  // templatefile ausgeben
    include('design/footer.php'); //footer einbinden
    ?>




wird nur das ausgegeben:


    assign("welcome", $lang['welcome']); $tpl->printToScreen(); // templatefile ausgeben include('design/footer.php'); //footer einbinden ?>



WARUM DAS?

Wäre über Hilfe und Aufklärung erfreut!

grüße
Valentin ;-)

PS:
Also ich will den Inhalt der Datei auslese,
bzw in einem textarea ausgeben.


Antwort schreiben

Antwort 1 von greg68 vom 08.02.2019, 11:00 Options

Hallo,

versuchs doch mal nach dem Muster:

<?
$fn="datei.txt";

$fp=fopen($fn, "r");
$inhalt=fread($fp, filesize($fn));
fclose($fp);

echo "<input type='textarea'  value='$inhalt'>
</textarea>";
?> 


Gruss

Antwort 2 von TombDevil vom 08.02.2019, 11:04 Options

Hi Valentin,

weil echo() HTML ausgibt und deshalb den Teil von <?php bis zum ersten $tpl-> als HTML-Tag interpretiert. Du wirst sehen, dass es im Browserquelltext steht, nur nicht angezeigt wird.

Lösung:
Wandle vor der Ausgabe HTML-Tags um mit htmlentities(), also

echo('<PRE>'.htmlentities($content).'</PRE>');


Ciao
TombDevil

Antwort 3 von Valentin vom 08.02.2019, 11:16 Options

Hallo,

ich habe jetzt

$content = file_get_contents($file);
echo('<PRE>'.htmlentities($content).'</PRE
>');


drinnen, aber es ist das selbe problem, im quelltext von firefox steht nun:

<textarea id="elm1" name="elm1" rows="15" cols="80">
<PRE>&lt;?php

include ('sys/common.php');
$tpl-&gt;assign(&quot;welcome&quot;, $lang['welcome']);
$tpl-&gt;printToScreen(); // templatefile ausgeben
include('design/footer.php'); //footer einbinden
?&gt;</PRE></textarea>


ausgegeben wird:


<pre>
assign(&quot;welcome&quot;, $lang[&#39;welcome&#39;]);
$tpl-&gt;printToScreen(); // templatefile ausgeben
include(&#39;design/footer.php&#39;); //footer einbinden
?&gt;
</pre>


Danke schon mal für eure Hilfe.

Valentin

Antwort 4 von Valentin vom 08.02.2019, 11:18 Options

Nachtrag (sry wegen doppelpost):

wenn ichs ohne textarea mache geht es nun !

Antwort 5 von Valentin vom 08.02.2019, 11:21 Options

(*Z* dreifachpost O.o)


also es geht bei nem normalen texarea doch, allerdings habe ich den tiny_mce. editor und da gehts nich... hmm...

Antwort 6 von Valentin vom 12.02.2019, 08:56 Options

Hallo, ich wollte noch mal fragen ob irgendwer noch eine Lösung kennt... sonst muss ich alles umbauen. :-/

danke!
valentin

Antwort 7 von Bernd124 vom 28.02.2019, 20:30 Options

Hallo,
habe ein ähnliches Problem, hat jemand eine Lösung gefunden?

Beste grüße
bernd

Ähnliche Themen

Problem mit PhP
Firefighter-nb  16.04.2007 - 149 Hits - 1 Antwort

html file zu php
Mirco151  04.07.2007 - 170 Hits - 1 Antwort

PHP Problem - Text aus Datenbank auslesen wo PHP Code drinsteht?!
Kuscheltier  10.11.2007 - 126 Hits - 3 Antworten

selectbox auslesen mit php
newi  31.01.2008 - 43 Hits - 4 Antworten

Ich möchte den Quelltext (php) ausgeben lassen
horschtiiiiii  19.03.2008 - 129 Hits - 2 Antworten

Hinweis

Diese Frage ist schon etwas älter, Sie können daher nicht mehr auf sie antworten. Sollte Ihre Frage noch nicht gelöst sein, stellen Sie einfach eine neue Frage im Forum..

Neue Einträge

Version: supportware 1.9.150 / 10.06.2022, Startzeit:Thu Jan 8 21:07:44 2026