Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
When you start to make the transition from static pages into dynamic pages, you begin to work in more programming type environments. And in a programming environment, unlike in a standard HTML environment it's very important to add comments to your code. If you come back in and let's say there is a five page process, that's creating a single page for your user, you do not want to have to go through all five pages to figure out what all the coding does in order to make a change to that page. Or one of the pages in that process moving forward so its important to have each piece of code commented so when you go into it later, you don't have to figure out the entire page concept you can focus on the code block that actually does what you need to change.
So I'll show you not just how to comment in PHP but also how to work with the commenting features. Within dream weaver. Now I want to add a comment above this line and no this code is not difficult I can easily read it and see what it does. But the concept of adding comments to every code block is a good one to get in the habit of doing, and whenever I do my courses we don't have time to plug comments in as we're working through the course.
So it's something I try and stress at the beginning when you're working on your own always add comments.immediately. If you say you're going to go back in and comment later it just never happens. The other piece I do with comments is, especially if I'm working with client's pages. I will not only comment out what the code does but if there's a particular person who approved it, or a particular date. I will add that into my comments as well. So let's add a PHP comment. And what I'm going to say is this displays our Hello World variables. Now I'm going to take that area there inside the code block, copy it, and I'm going to move it outside the code block as well. So we have it listed with in the PHPs, we also have it listed outside of it. This one above the PHPs needs to be an HTML comment. So I will move over the Commenting tool bar.
I should say the Coding tool bar has a commenting area. And it's this little area that looks like somebody's speaking. And if I click on that there are a few different types of comments available. Since this one we want to be an HTML comment I will apply an HTML comment to that one. Now, it did move the lower part of this comment down to the next page, you can drag and drop in Dreamweaver, so I'll just drag it to the other side just to keep it neat.
Now PHP is not happy with this information, because PHP does not understand it. So I will select that line, and there are two different ways to comment in PHP within Dreamweaver that is; I can click this area, just to the right of echo, and if I do that, I get this type of PHP comment. There are a couple of other ways you can comment in PHP as well. But not to confuse the issue, I'll show you how to remove a comment.
And that's the one with the red X, that gets rid of a comment that might be there. The other type of PHP comment is this middle one here apply comment. You can see it now turns orange so PHP comments are orange HTML comments are gray. Let's put this in the browser and show you the difference. So I have my Hello World being displayed, and if I go to view page source, or view source, depending upon the browser you're in.
Notice this line right under the body tag, with the HTML comments, is showing in the browser. What is not showing is any of this PHP piece other than the values for our variables. So the only thing showing is what's inside those double quotes. PHP has taken our variable declarations, it has converted it into values and Hello World is being displayed. PHP also strips out any PHP comments and the code block says well. So none of this PHP coding is going to show in the browser. That's why you as a user cannot go into a browser and view source to see any silverside language features or coding.
It's strict out by the silverside language before it sent to the browser. So that is adding comments in PHP, very important concept. I'm afraid I don't have time to stress that with the topics we're going to cover in the amount of time we have. But please try and get into the habit of commenting your code, you'll be very happy you did moving forward.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 105070 Viewers
56 Video lessons · 116856 Viewers
71 Video lessons · 86076 Viewers
131 Video lessons · 41172 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.