Topic Closed
458 Posts
5 Themes
9 Plugins

I am working at a plugin and want  to import  a textfile( or table.txt)  into readfirst_x1.php and echo it in a div - but i get only errors.

echo " TEST "; gives of course TEST - but echo ' <span><font-family ...> gives an error about   font (after-interpreted though any string should have an output)

The textfile is in the same folder as readfirst_x1.php  ( i had this problem also in another context before)

label = 'Please read details'
script = 'readfirst_x1.php'

I added in the php-file  :

 echo "<hr> <div> <br>";
$file = '';
$orig = file_get_contents($file);
$anoto = htmlentities($orig);

echo '<code>';
echo '<pre>';

echo $anoto;

echo '</pre>';
echo '</code>';
echo " End " ;   /*  this String appears !  */
 echo "</div>";

This gives only a broad gray line and END in the next line. Is there a special syntax for plugins ? Who knows a general solution ?

global $addonPathCode;
$plg = $addonPathCode;
$tab1 = '/';
$file = $plg . $tab1 ;
if (file_exists($file))
{ echo "<br> The file $file exists"; }  /* it exists ! */
$f = fopen($file, "r") or exit("Unable to open file!");

{   echo fgets($f)."<br />"; }  fclose($f);

gives no output

A 'solution' ala                 does not function either - nor readfile()


P:S i found the solution : The 1st soultion give me to pages of empty screen, so i did not see that the echo file_get_contents( $file ); functions, whose code appaeared behind. ( Mc Murphy)

$f = fopen($file, "r") or exit("Unable to open file!");
// read file line by line until the end of file (feof) 
 if (file_exists($file)) {
 readfile( $file ); }---
 echo file_get_contents( $file );

Edited: 5 years ago#10944

1.5K Posts
16 Plugins

IMO it largely depends on the content and origin of the text file.

To check a PHP variable you can (almost) always use sth. like …

msg('$myVariable = ' . pre($myVariable) );

which will output the variable's type and content in a message.
This will work with strings, numbers, booleans and arrays.

If the text file can be trusted in terms of security, you could also simply try



$myText = ob_get_clean();

echo '<pre>';
echo $myText;
echo '</pre>';

While developing, I'd also recommend to set the gpdebug constant to true in /gpconfig.php, which makes Typesetter quite verbose in terms of notices, warnings and errors.

Edited: 5 years ago#10946

1.5K Posts
16 Plugins
If you don't want to use <pre> to keep linebreaks, you could also try nl2br.
Edited: 5 years ago#10947

Topic Closed



elFinder 2.1.50 in Upcoming Release

A new release for Typesetter is in the works with a lot of improvements including the ... Read More

Typesetter 5.1

Typesetter 5.1 is now available for download. 5.1 includes bug fixes, UI/UX improvements, ... Read More

More News

Log In