Greetings
im opening a file in php and saving it to a variable. I’m trying to echo that variable inside a html
Well, it looks like you are reading one line at a time. You might want to use file-get instead.
But, note that you are reading one line at a time into one variable. Therefore, the data for the LAST line read is what stays inside of $line.
If you wanted all of the data from the file, you can use fread to read it all or you can alter your current code to append the lines.
So, to append. Instead of “$line = fgets(handle)” Use “$line .= fgets($file_handle);”
The .= means to add the value to the current value. Minor change of adding one period makes an entire difference in what the code does.
Hope that is what you were looking for… Good luck…