Reputation: 478
I try to read in a bash script from a text file and print it to the screen via php.
I tried
$code = @file_get_contents( $myFileName );
as well as
$code = "";
$myFile = fopen($myFileName, "r");
while ($line = fgets($myFile)) {
$code .= $line;
}
However, the string I get from reading in the file doesn't contain all of the file's contents. The problem is that the text file contains the string
<<EOF
After that the String abruptly stops.
How come? It seems weird to me that php isn't able to deal with those few characters and misinterpret them as the actual EOF.
Is there a way I can read in the whole file?
Thanks in advance!
Upvotes: 0
Views: 224
Reputation: 944009
When I try it, I don't experience that problem therefore, presumably, you are outputting the text to an HTML document and testing your code by looking at the rendering of that document in a browser (as opposed to looking at the raw output of the script, as would appear in View > Source).
In HTML <
indicates the start of a tag. You need to escape your HTML with htmlspecialchars()
for <
to be treated as data instead of markup.
Upvotes: 6