<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=PHP-and-MySQL%2FC2%2FCommon-Way-to-Display-HTML%2FEnglish</id>
		<title>PHP-and-MySQL/C2/Common-Way-to-Display-HTML/English - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=PHP-and-MySQL%2FC2%2FCommon-Way-to-Display-HTML%2FEnglish"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C2/Common-Way-to-Display-HTML/English&amp;action=history"/>
		<updated>2026-05-15T13:30:35Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.17</generator>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C2/Common-Way-to-Display-HTML/English&amp;diff=546&amp;oldid=prev</id>
		<title>Chandrika: Created page with '{| border=1 !Time !Narration |- |0:00-0:21 |Here is a tip for displaying HTML inside your php . This is specially useful when you are using ‘if’ statements or anything that u…'</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C2/Common-Way-to-Display-HTML/English&amp;diff=546&amp;oldid=prev"/>
				<updated>2012-11-29T06:41:41Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;#039;{| border=1 !Time !Narration |- |0:00-0:21 |Here is a tip for displaying HTML inside your php . This is specially useful when you are using ‘if’ statements or anything that u…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{| border=1&lt;br /&gt;
!Time&lt;br /&gt;
!Narration&lt;br /&gt;
|-&lt;br /&gt;
|0:00-0:21&lt;br /&gt;
|Here is a tip for displaying HTML inside your php . This is specially useful when you are using ‘if’ statements or anything that uses a block and when you need to do this on a condition or you need to output a lot of HTML inside something that is working on php.&lt;br /&gt;
|-&lt;br /&gt;
|0:22-0:29&lt;br /&gt;
|In this example, I’ve got a variable- Name, and this is set  to Alex.&lt;br /&gt;
|-&lt;br /&gt;
|0:30-0:35&lt;br /&gt;
|so if i type-  name equals Alex, then, it will echo out “Hi, Alex”&lt;br /&gt;
|-&lt;br /&gt;
|0:36-0:46&lt;br /&gt;
|If name is not equal to Alex-so we type ‘else’- we will echo out “You are not Alex.  Please type your name”.&lt;br /&gt;
|-&lt;br /&gt;
|0:47-0:52&lt;br /&gt;
|And we have an input field here which should have a form around it.  &lt;br /&gt;
|-&lt;br /&gt;
|0:53-1:01&lt;br /&gt;
|So,  “Form action equals Index.php”&lt;br /&gt;
Method =post   &lt;br /&gt;
And we end the form  here.&lt;br /&gt;
|-&lt;br /&gt;
|1:02-1:14&lt;br /&gt;
|We can bring this down a bit, so that it looks better. So, we have  some HTML codes inside this Else block .  &lt;br /&gt;
|-&lt;br /&gt;
|1:15-1:26&lt;br /&gt;
|So we type ‘If else’ and we have got a block starting here,  and a block ending here.  And what could be a lot of HTML code.&lt;br /&gt;
|-&lt;br /&gt;
|1:27-1:33&lt;br /&gt;
|The purpose of this tutorial is to show you that you don’t need to use Echo and echo out HTML code.  &lt;br /&gt;
|-&lt;br /&gt;
|1:34-1:40&lt;br /&gt;
|It’s easier and saves time when you want to code using quotation marks rather than single inverted commas..&lt;br /&gt;
|-&lt;br /&gt;
|1:41-1:51&lt;br /&gt;
|Also it’s nicer to have a code inside the blocks ,say, this block here without having to worry about what you are typing. &lt;br /&gt;
|-&lt;br /&gt;
|1:58-2:08&lt;br /&gt;
|So, if you are used to quotation marks this forward slash will  escape the character.  &lt;br /&gt;
|-&lt;br /&gt;
|2:09-2:18  &lt;br /&gt;
|So, it will be displayed but  will be ignored  as the end of the Echo and the beginning of this Echo here.&lt;br /&gt;
|-&lt;br /&gt;
|2:19-2:24&lt;br /&gt;
|For example.  Let’s just refresh.&lt;br /&gt;
|-&lt;br /&gt;
|2:25-2:30&lt;br /&gt;
|Since name equals Alex it is greeting me as we saw earlier.&lt;br /&gt;
|-&lt;br /&gt;
|2:31-2:41&lt;br /&gt;
|The Echo is okay for a small amount of text but for a large amount with a form etc,  we don’t want  the echo.&lt;br /&gt;
|-&lt;br /&gt;
|2:42-2:55&lt;br /&gt;
|As it stands at present , it won't run. We will receive an error . We haven't provided a method of output for this text.&lt;br /&gt;
|-&lt;br /&gt;
|2:56-3:07&lt;br /&gt;
|That’s on line 12. So, if you go to line 12, you will see that it is here.  We can rectify the problem in this way.&lt;br /&gt;
|-&lt;br /&gt;
|3:08-3:18&lt;br /&gt;
|We have our  php opening tag here. And I am going to end the tag down here .&lt;br /&gt;
|-&lt;br /&gt;
|3:19-3:29&lt;br /&gt;
|So, we are ending the tag after the block starts. Now I will start a new tag just before the curly bracket here.&lt;br /&gt;
|-&lt;br /&gt;
|3:30-3:45&lt;br /&gt;
|So now we have a chunk of php code here and a chunk here.  And the rest here is not interpreted as php.  Since it is HTML it will be displaced as HTML code.&lt;br /&gt;
|-&lt;br /&gt;
|3:46-4:01&lt;br /&gt;
|So, what I am going to do first is change all these to quotation marks.  &lt;br /&gt;
|-&lt;br /&gt;
|4:02-4:06&lt;br /&gt;
|If you implement this method from the beginning ,  you could code easily and it would work a lot better.&lt;br /&gt;
|-&lt;br /&gt;
|4:07-4:20&lt;br /&gt;
|So once again as is visible on the screen we have a block here and the block here.  It may appear as though the  php would end here .&lt;br /&gt;
|-&lt;br /&gt;
|4:21-4:36&lt;br /&gt;
|But we have not ended a block inside here, in this area , but we are going down here.  We aren’t echoing out but displaying this.  &lt;br /&gt;
|-&lt;br /&gt;
|4:37-4:47&lt;br /&gt;
|This applies specifically to the Else block. We end the block in the blue highlighted line here and here .&lt;br /&gt;
|-&lt;br /&gt;
|4:46-4:58&lt;br /&gt;
|So again we will first get “Hi, Alex”. Now if we change the name to Let’s say Kyle, refresh.&lt;br /&gt;
|-&lt;br /&gt;
|4:58-5:07&lt;br /&gt;
|You will see that the HTML has been displayed properly.  But it hasn’t been echoed out using php.&lt;br /&gt;
|-&lt;br /&gt;
|5:08 onwards.&lt;br /&gt;
|This is a good method to use when you want to display HTML properly and re- read easily.  Hope this tutorial has been helpful .Thank you for watching.&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Chandrika</name></author>	</entry>

	</feed>