PHP-and-MySQL/C2/Echo-Function/English

From Script | Spoken-Tutorial
Jump to: navigation, search
Time Narration
0:00 Hi guys. This is a basic PHP tutorial.
0:03 I'm just going to run through how to use the echo function and how to set your tags up.
0:08 Right, those of you that are familiar with html, will know that there are your html tags to start your page, to end your page.
0:15 They're not vital in an html page. As long as you've got an html extension, you're fine.
0:20 However in PHP, you need your tags. This starts, this ends, and that's basically the standard notation for it.
0:29 However, our content goes in between here.
0:32 Right, I've already saved my file, that's 'helloworld.php'.
0:36 So, let's give that a save and have a look in here.
0:41 Right, okay there's nothing in the page at the moment, but we've got our page set up, it's absolutely fine.
0:47 The echo function works like this: we've got echo, we've got some speech marks and we've got a line terminator which is the semicolon on your keyboard.
0:57 And, our text goes in between here. Let's save that out and we'll refresh and there we go.
1:05 Right, you can – and I find this very useful – write your echo function like this.
1:10 Because when you put an html code inside your echo function (and just to let you know, if you haven't learnt html yet I suggest you pick it up, at least slightly, because we're going to be using it quite a lot) these bits here don't represent line breaks, for that you need to add your own html in, so '
' for line break, and then 'New line'.
1:28 We'll refresh this, and there you go: our html has been incorporated.
1:33 Okay, just to let you know, this is one thing that a lot of people run into: 'image source equals' and your file goes there.
1:42 However, what we've got at the moment is we've got 'echo', this shows that we're going to start our output, and this here will show that we're ending our output.
1:52 We don't end it here, we're going to end it here. So instead of these, we'll need inverted commas – basically, that will let us show our image there. There's no file specified, but you get the picture.
2:05 So, let me just show you what would happen if we keep these in, and then that's pretty much the end of the tutorial.
2:13 Right, we've got 'parse error' – we either need a comma or a semicolon to end, which proves that as we're coming up to here, we need a semicolon after this.
2:23 But in actual fact, that's rubbish. So, just keep them as inverted commas.
2:30 Okay, that's the basics of the echo function and the PHP tags, that's all you really need to know for now. Thanks for watching!

Contributors and Content Editors

Manivel