PHP isn't stripping anything; your browser is ignoring the space. Right-click, View Source and you'll see what I mean. Either wrap the whole string in a <pre>
tag, or use a non-breaking space, e.g.,
, for each piece of whitespace you want to leave. (Or use style='white-space: pre;'
on the element.)
echo ' the quick brown fox jumps over the lazy dog.';
Or:
echo '<pre> the quick brown fox jumps over the lazy dog.</pre>';
Or:
echo '<p style="white-space: pre;"> the quick brown fox jumps over the lazy dog.</p>';
Or (@SecondRekudo):
Or send a Content-type: text/plain header.
Which would look like:
header('Content-type: text/plain');
Which needs to be called before any output to the browser (or you'll get a warning and the header won't be sent).