1 00:00:00 --> 00:00:13 This is a short tutorial on how to embed Php code inside HTML code. This is very useful in many situations. 2 00:00:14 --> 00:00:22 For example if I were to create Php tags and echo out my name here. 3 00:00:23 --> 00:00:29 By running this , let's click on a file, we just get an Alex. 4 00:00:30 --> 00:00:37 Now for example, I can embed HTML inside this and echo it out here to make Alex a little bolder. 5 00:00:38 --> 00:00:44 But what I can do is I can switch this the other way round. 6 00:00:45 --> 00:00:51 Let's start again, create an HTML page. I'm going to use this example 7 00:00:52 --> 00:01:12 I will start a Php and a tag here. I echo out Alex and then come in outside the Php tags and add my bold here and my bold end after the ending Php tag 8 00:01:13 --> 00:01:19 And it gives us the same result, nothing has changed even though I've refreshed the page 9 00:01:20 --> 00:01:25 So, we can change that to underline and you can see that Alex is underlined. 10 00:01:26 --> 00:01:38 So, we can do it either ways. It's up to you to use the HTML code inside the echo or not. But there are more uses to this. 11 00:01:39 --> 00:01:47 Now, if you do know HTML, you know the input tag is a template tag. 12 00:01:48 --> 00:01:55 So, let's say text and the name of this will be name and the value is going to be equal to Alex 13 00:01:56 --> 00:02:13 Lets refresh this and we see we've got a text box here with Alex inside.Now I want to use Php to grab the get variable header and put it inside this value of our input value. 14 00:02:14 --> 00:02:29 Now, this is really useful in some cases like form submission and error checking where you want the posted variables to stay inside the value of each text box. 15 00:02:30 --> 00:02:37 If you haven't seen the get tutorial already make sure you watch that. 16 00:02:38 --> 00:02:47 Now, bring this down a couple of lines, obviously we still run this code successfully because it works on similar line basis 17 00:02:48 --> 00:02:57 So, this you see here is exactly the same as that, you just have to force it down a bit and I'm going to create Php text here 18 00:02:58 --> 00:03:07 This is going to look a funny brown colour because we're working in Php highlighting and it's not really recognizing this type of highlighting 19 00:03:08 --> 00:03:11 Ok, I'm just going to echo out Alex 20 00:03:12 --> 00:03:24 Since this works on a single line basis, bring this all up on a single line. So now I have embed this inside that and your embedding is done. 21 00:03:25 --> 00:03:34 By refreshing we get the value of Alex. We're echoing out now Php inside a n HTML value 22 00:03:35 --> 00:03:39 So, we're using Php code inside our value here 23 00:03:40 --> 00:03:49 I'm going to demonstrate dollar underscore get ,remember using the single quotes 24 00:03:50 --> 00:03:54 I'm going to say name and then refresh 25 00:03:55 --> 00:04:03 Nothing's happened so type in name=Alex which gives us Alex inside that 26 00:04:04 --> 00:04:10 Type in name=Kyle. It gives us Kyle inside that 27 00:04:11 --> 00:04:15 Basically you can embed any Php code you want inside that 28 00:04:16 --> 00:04:27 Try saying echo Php info and you'd get a very funny result 29 00:04:28 --> 00:04:32 This is the HTML code of Php info document 30 00:04:33 --> 00:04:36 So, you can see that there's loads of code in that 31 00:04:37 --> 00:04:45 Here we're just working with Php inside.The only thing you need to worry about is being careful with your single and double quotes 32 00:04:46 --> 00:04:52 So this was the basic tutorial on embedding Php code inside HTML code 33 00:04:53 --> 00:04:55 I hope it was useful.Thanks for watching 34 00:04:56 --> 00:05:01 This is Anoushka dubbing for the Spoken tutorials Project