I was wondering how can I add extra whitespace in php is it something like \\s
please help thanks.
Is there a tutorial that list these kind of things th
for adding space character you can use
<?
echo "\x20\x20\x20";
?>
is this for display purposes? if so you really should consider separating your display form your logic and use style sheets for formatting. being server side php should really allow providing and accepting data. while you could surely use php to do what you are asking I am a very firm believer in keeping display and logic with as much separation as possible. with styles you can do all of your typesetting.
give output class wrappers and style accordingly.
to make your code look better when viewing source
$variable = 'foo';
echo "this is my php variable $variable \n";
echo "this is another php echo here $variable\n";
your code when view source will look like, with nice line returns thanks to \n
this is my php variable foo
this is another php echo here foo
you can use the <pre>
tag to prevent multiple spaces and linebreaks from being collapsed into one. Or you could use
for a typical space (non-breaking space) and <br />
(or <br>
) for line breaks.
But don't do <br><br><br><br>
just use a <p>
tag and adjust the margins with CSS.
<p style="margin-top: 20px;">Some copy...</p>
Although, you should define the styles globally, and not inline as I have done in this example.
When you are outputting strings from PHP you can use "\n" for a new line, and "\t" for a tab.
<?php echo "This is one line\nThis is another line"; ?>
Although, flags like \n or \t only work in double quotes (") not single wuotes (').
PHP (typically) generates HTML output for a web-site.
When displaying HTML, the browser (typically) 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.
when you add more space between double quotes or single quotes PHP takes only one white space ,so if you want to add more white space between words or strings use tab '\t' sequence
echo "\t";