Answer the question
In order to leave comments, you need to log in
How to properly output source code from a file?
The server contains text files of formatted source code.
Script that produces the file:
<?php
$file = $_GET["code"].'.txt';
$text = file_get_contents($file);
echo nl2br( $text );
?>
$http({
method: 'GET',
url: url+'code.php?code='+item.path
}).then(function successCallback(response) {
$scope.SRCCode.code = response.data;
}, function errorCallback(response) {
});
<code class=" language-cpp">
{{SRCCode.code}}
Answer the question
In order to leave comments, you need to log in
Try echo nl2br( $text );
to replace with echo $text;
and output through the tag <pre>
, it looks like you are shielded during the output <br/>
as a bonus, save the formatting with spaces ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question