1 00:00:00 --> 00:00:22 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. 2 00:00:23 --> 00:00:29 In this example, I’ve got a variable- Name, and this is set to Alex. 3 00:00:30 --> 00:00:35 so if i type- name equals Alex, then, it will echo out “Hi, Alex” 4 00:00:36 --> 00:00:46 If name is not equal to Alex-so we type ‘else’- we will echo out “You are not Alex. Please type your name”. 5 00:00:47 --> 00:00:52 And we have an input field here which should have a form around it. 6 00:00:53 --> 00:01:04 So, “Form action equals Index.php” Method =post And we end the form here. 7 00:01:05 --> 00:01:14 We can bring this down a bit, so that it looks better. So, we have some HTML codes inside this Else block . 8 00:01:15 --> 00:01:26 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. 9 00:01:27 --> 00:01:33 The purpose of this tutorial is to show you that you don’t need to use Echo and echo out HTML code. 10 00:01:34 --> 00:01:40 It’s easier and saves time when you want to code using quotation marks rather than single inverted commas.. 11 00:01:41 --> 00:01:57 Also it’s nicer to have a code inside the blocks ,say, this block here without having to worry about what you are typing. 12 00:01:58 --> 00:02:07 So, if you are used to quotation marks this forward slash will escape the character. 13 00:02:08 --> 00:02:19 So, it will be displayed but will be ignored as the end of the Echo and the beginning of this Echo here. 14 00:02:20 --> 00:02:24 For example. Let’s just refresh. 15 00:02:25 --> 00:02:30 Since name equals Alex it is greeting me as we saw earlier. 16 00:02:31 --> 00:02:43 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. 17 00:02:44 --> 00:02:58 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. 18 00:02:59 --> 00:03:08 That’s on line 12. So, if you go to line 12, you will see that it's here. We can rectify the problem in this way. 19 00:03:09 --> 00:03:15 We have our php opening tag here. And I am going to end the tag down here . 20 00:03:16 --> 00:03:30 So, we are ending the tag after the block starts. Now I will start a new tag just before the flower brackets or curly bracket here. 21 00:03:31 --> 00:03:48 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. 22 00:03:49 --> 00:03:55 So, what I am going to do first is change all these to quotation marks. 23 00:03:56 --> 00:04:07 If you implement this method from the beginning , you could code easily and it would work a lot better. 24 00:04:08 --> 00:04:21 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 . 25 00:04:22 --> 00:04:36 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. 26 00:04:37 --> 00:04:46 This applies specifically to the Else block. We end the block in the blue highlighted line here and here . 27 00:04:47 --> 00:05:00 So again we will first get “Hi, Alex”. Now if we change the name to Let’s say Kyle, refresh. 28 00:05:01 --> 00:05:08 You will see that the HTML has been displayed properly. But it hasn’t been echoed out using php. 29 00:05:09 --> 00:05:14 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.