note 112847 deleted from language.basic-syntax by levim
| From: | levim@php.net | Date: | Wed, 04 Sep 2013 18:47:38 +0000 |
| Subject: | note 112847 deleted from language.basic-syntax by levim | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196161@lists.php.net to get a copy of this message | ||
Note Submitter: Katta
----
I hope di note will help the novice or who is a little bit distracted:
When you echo a string with HTML tags within, they will not be shown in output:
<?php
// This example will print "Hello World", not "<p>Hello
World!</p>"
echo "<p>Hello World!</p>";
?>
But why? It's really simple: when a PHP function like echo or print is called, its argument is
sent to the browser.
The browser distinguishes between tags and plain text: the combination of "<" symbol
and any latin character is considered as a tag, and everything after it is treated as tag parameter
until a ">" symbol is found.
<?php
// Everything after "<h" is considered as a parameter
// This example print "This will be".
echo "This will be <h show>"
?>
As you should know:
- HTML tags make up the web pages structure.
- The (X)HTML documents don't show their own structure in normal web pages.
That's why HTML tags won't be shown.
In order to show HTML tags, you have to use the HTML entity "<", which represent
the "<" symbol.
Example:
<?php
// This example will print "<p>Hello World!</p>"
echo "<p>Hello World!</p>";
?>
I tried to be clear as much as possible, sorry for my bad english.