Some examples:
Code:str_repeat(' ', 5); // adds 5 spaces
|
and
Code:Actually PHP generates HTML output for a web-site. When displaying HTML, the browser collapses all whitespace in text into a single space. Sometimes, between tags, it even collapses whitespace to nothing. In order to persuade the browser to display whitespace, you need to include special tags like or <br/> in your HTML to add non-breaking whitespace or new lines, respectively.
To render more than one whitespace on most web browsers use instead of normal white spaces.
|
Code:echo "<p>Hello punt"; // This will render as Hello Punt (with 4 white spaces)
echo "<p> Hello punt"; // This will render as Hello punt (with one space)
|
For showing data in raw format (with exact number of spaces and "enters") use HTML <pre> tag.
Code:echo "<pre>Hello punt</pre>"; //Will render exactly as written here (8 white spaces)
|