Difference between revisions of "PHP-and-MySQL/C2/Common-Way-to-Display-HTML/English-timed"
From Script | Spoken-Tutorial
Pravin1389 (Talk | contribs) |
Sandhya.np14 (Talk | contribs) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{| border=1 | {| border=1 | ||
− | + | |'''Time''' | |
− | + | |'''Narration''' | |
|- | |- | ||
− | | | + | |00:00 |
− | |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. | + | |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'''. |
|- | |- | ||
− | | | + | |00:23 |
− | |In this example, I’ve got a variable- | + | |In this example, I’ve got a variable- '''name''' and this is set to "alex". |
|- | |- | ||
− | | | + | |00:30 |
− | | | + | |So, if I type- '''$name''' equals '''alex''' then it will '''echo''' out “Hi, Alex”. |
|- | |- | ||
− | | | + | |00:36 |
− | |If name is not equal to Alex-so we type | + | |If '''$name''' is not equal to "Alex" - so we type '''else'''- we will echo out “You are not Alex. Please type your name”. |
|- | |- | ||
− | | | + | |00:47 |
− | |And we have an input field here which should have a form around it. | + | |And we have an '''input''' '''field''' here which should have a '''form''' around it. |
|- | |- | ||
− | | | + | |00:53 |
− | |So, | + | |So, '''form action''' equals 'Index.php' |
− | + | '''method =''' 'POST' | |
− | + | and we end the '''form''' here. | |
|- | |- | ||
− | | | + | |01:05 |
− | |We can bring this down a bit | + | |We can bring this down a bit so that it looks better. So, we have some '''HTML code''' inside this '''else''' block . |
|- | |- | ||
− | | | + | |01:15 |
− | |So we type ‘If else’ and we have got a block starting here | + | |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'''. |
|- | |- | ||
− | | | + | |01:27 |
− | |The purpose of this tutorial is to show you that you don’t need to use | + | |The purpose of this tutorial is to show you that you don’t need to use '''echo''' and echo out '''HTML code'''. |
|- | |- | ||
− | | | + | |01:34 |
− | |It’s easier and saves time when you want to code using quotation marks rather than single inverted commas | + | |It’s easier and saves time when you want to code using quotation marks rather than single inverted commas. |
|- | |- | ||
− | | | + | |01:41 |
− | |Also it’s nicer to have a code inside the blocks ,say, this block here without having to worry about what you are typing. | + | |Also it’s nicer to have a code inside the blocks, say, this block here without having to worry about what you are typing. |
|- | |- | ||
− | | | + | |01:58 |
− | |So, if you are used to quotation marks this forward slash will | + | |So, if you are used to quotation marks this forward slash will escape the character. |
|- | |- | ||
− | | | + | |02:08 |
− | |So, it will be displayed but | + | |So, it will be displayed but will be ignored as the end of the '''echo''' and the beginning of this '''echo''' here. |
|- | |- | ||
− | | | + | |02:20 |
− | |For example | + | |For example: let’s just '''refresh'''. |
|- | |- | ||
− | | | + | |02:25 |
− | |Since name equals Alex it is greeting me as we saw earlier. | + | |Since '''name''' equals "Alex", it is greeting me as we saw earlier. |
|- | |- | ||
− | | | + | |02:31 |
− | |The | + | |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'''. |
|- | |- | ||
− | | | + | |02:44 |
− | |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. | + | |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. |
|- | |- | ||
− | | | + | |02:59 |
|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. | |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. | ||
|- | |- | ||
− | | | + | |03:09 |
− | |We have our php opening tag here | + | |We have our '''php''' opening '''tag''' here and I am going to end the tag down here. |
|- | |- | ||
− | | | + | |03:16 |
− | |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. | + | |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. |
|- | |- | ||
− | | | + | |03:31 |
− | |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 | + | |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 displayed as '''HTML code'''. |
|- | |- | ||
− | | | + | |03:49 |
− | |So, what I am going to do first is change all these to quotation marks. | + | |So, what I am going to do first is, change all these to quotation marks. |
|- | |- | ||
− | | | + | |03:56 |
− | |If you implement this method from the beginning , | + | |If you implement this method from the beginning, you could code easily and it would work a lot better. |
|- | |- | ||
− | | | + | |04:08 |
− | |So once again as is visible on the screen we have a block here and the block here. It may appear as though the | + | |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 |
|- | |- | ||
− | | | + | |04:22 |
− | | | + | |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. |
|- | |- | ||
− | | | + | |04:37 |
− | |This applies specifically to the | + | |This applies specifically to the '''else block'''. We end the block in the blue highlighted line here and here. |
|- | |- | ||
− | | | + | |04:47 |
− | |So again we will first get “Hi, Alex”. Now if we change the name to | + | |So again, we will first get “Hi, Alex”. Now if we change the name to let’s say "Kyle", '''refresh'''. |
|- | |- | ||
− | | | + | |05:01 |
− | |You will see that the HTML has been displayed properly. But it hasn’t been echoed out using php. | + | |You will see that the HTML has been displayed properly. But it hasn’t been echoed out using '''php'''. |
|- | |- | ||
− | | | + | |05:09 |
− | |This is a good method to use when you want to display HTML properly and | + | |This is a good method to use when you want to display HTML properly and read it easily. Hope this tutorial has been helpful .Thank you for watching. |
|- | |- |
Latest revision as of 17:44, 26 May 2015
Time | Narration |
00:00 | 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. |
00:23 | In this example, I’ve got a variable- name and this is set to "alex". |
00:30 | So, if I type- $name equals alex then it will echo out “Hi, Alex”. |
00:36 | If $name is not equal to "Alex" - so we type else- we will echo out “You are not Alex. Please type your name”. |
00:47 | And we have an input field here which should have a form around it. |
00:53 | So, form action equals 'Index.php'
method = 'POST' and we end the form here. |
01:05 | We can bring this down a bit so that it looks better. So, we have some HTML code inside this else block . |
01:15 | 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. |
01:27 | The purpose of this tutorial is to show you that you don’t need to use echo and echo out HTML code. |
01:34 | It’s easier and saves time when you want to code using quotation marks rather than single inverted commas. |
01:41 | Also it’s nicer to have a code inside the blocks, say, this block here without having to worry about what you are typing. |
01:58 | So, if you are used to quotation marks this forward slash will escape the character. |
02:08 | So, it will be displayed but will be ignored as the end of the echo and the beginning of this echo here. |
02:20 | For example: let’s just refresh. |
02:25 | Since name equals "Alex", it is greeting me as we saw earlier. |
02:31 | 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. |
02:44 | 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. |
02:59 | 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. |
03:09 | We have our php opening tag here and I am going to end the tag down here. |
03:16 | 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. |
03:31 | 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 displayed as HTML code. |
03:49 | So, what I am going to do first is, change all these to quotation marks. |
03:56 | If you implement this method from the beginning, you could code easily and it would work a lot better. |
04:08 | 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 |
04:22 | 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. |
04:37 | This applies specifically to the else block. We end the block in the blue highlighted line here and here. |
04:47 | So again, we will first get “Hi, Alex”. Now if we change the name to let’s say "Kyle", refresh. |
05:01 | You will see that the HTML has been displayed properly. But it hasn’t been echoed out using php. |
05:09 | This is a good method to use when you want to display HTML properly and read it easily. Hope this tutorial has been helpful .Thank you for watching. |