note 112847 added to language.basic-syntax

From: Date: Mon, 29 Jul 2013 19:29:04 +0000
Subject: note 112847 added to language.basic-syntax
Groups: php.notes 
Request: Send a blank email to php-notes+get-195811@lists.php.net to get a copy of this message
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 "&lt;", which represent the "<" symbol. Example: <?php // This example will print "<p>Hello World!</p>" echo "&lt;p>Hello World!&lt;/p>"; ?> I tried to be clear as much as possible, sorry for my bad english. ---- Server IP: 69.147.83.199 Probable Submitter: 2.230.235.82 ---- Manual Page -- http://php.net/manual/en/language.basic-syntax.php Edit -- https://master.php.net/note/edit/112847 Del: integrated -- https://master.php.net/note/delete/112847/integrated Del: useless -- https://master.php.net/note/delete/112847/useless Del: bad code -- https://master.php.net/note/delete/112847/bad+code Del: spam -- https://master.php.net/note/delete/112847/spam Del: non-english -- https://master.php.net/note/delete/112847/non-english Del: in docs -- https://master.php.net/note/delete/112847/in+docs Del: other reasons-- https://master.php.net/note/delete/112847 Reject -- https://master.php.net/note/reject/112847 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#195811) next »