Video: Commenting codeCommenting code provides you with in-depth training on Developer. Taught by Candyce Mairs as part of the Dynamic Dreamweaver Websites: Creating and Validating Forms
Commenting code provides you with in-depth training on Developer. Taught by Candyce Mairs as part of the Dynamic Dreamweaver Websites: Creating and Validating Forms
Forms perform an essential function in modern websites, making it possible to gather information from users and validate that information. In this course, Adobe Certified Expert Candyce Mairs shows how to create forms to email user information and validate user data using various methods of form validation. These validation methods include client-side, server-side, and custom validation; CAPTCHA images; and Spry validation fields. You'll also see how to set up a PHP testing environment and preview PHP pages in Dreamweaver. Along the way you'll build your skills in areas like using admin consoles, commenting code, working with variables and includes, and much more.
- Installing XAMPP on a Windows system
- Installing MAMP on a Mac system
- Using admin consoles
- Creating PHP pages
- Commenting code
- Working with web forms
- Adding custom validation
- Using redirects
- Dealing with email issues
I want to talk about commenting your code when you begin working in PHP, or any type of programming. It's very important to comment your code in order for you to understand two, three, six months from now what you were doing within the pages. As you work in static pages, it's not too important particularly in HTML. So a lot of people moving into dynamic web sites using server side languages, tend not to remember to comment.
And it's a very important part of the process to save you time long term. So what we want to do is add a comment within our PHP code block. Now let me show you a couple of things with regards to comments. So I'm going to type out under the body tag, this code creates variables, and prints them to the page. Now this is such simple code.
Prints them to the page. Let me focus on what I'm doing here. So I'm going to make this comment an HTML comment, and DreamWeaver does have a commenting area... This little piece here, where it looks like it's somebody talking is how you apply a comment. This is how you remove a comment. So, if I want to make this an HTML comment, I use the first one. So, I'll go ahead and do that. You can see HTML comments turn a light gray.
Now, what if I put that same information inside the php code block. So this is the opening part of the code block, this is the closing portion, just like HTML has an opening and closing tag. So I'll paste that in. Whoops, looks like I didn't copy, just one second. I'll put a copy in here, and paste. There we go. Now notice what happens in dream weaver, it's telling me there's an error here.
Php can't understand this line of code. First of all php lines have to have a semi colon but in order to make this a comment I could do a couple of things. One is since I have this php tab up in my inset bar. I can go ahead, and if I highlight this piece, notice it say's comment. So I can comment in that manner. Now the html comment is gray, the php comment is orange, and notice I no longer have syntax errors..
So that's one type of comment. Now I'll select that and click the red X. And that'll remove the comment. Now, let me show you the other type of comment you can use in PHP. There's actually a couple of others. But I'll just show you one other. I can also apply that type of comment here. Or I can use this type of comment. And notice that turns orange. And I have no syntax errors. So that's one way to type out a comment.
Let me leave both of these comments in here. Let's save the page,and put it out in the browser. Now you can see your page doesn't look any different than it did before the comment. But what happens to our comments within the source code? This is my HTML comment that's showing in the source code. Any PHP within a PHP code block, the entire code block is stripped out and the page is sent back to the browser via the web server without any PHP coding in it.
And for people new to a server side language, you can get in the habit of not doing that, and I would strongly recommend you do that immediately. Think about putting a comment in each PHP code block. I also, if I modify something while I'm working on a website, I put a comment about why I modified it. The date I modified it, and my initials. Sometimes, I even put, depending upon the client, who approved the modification, so it gives you a way to store information within your pages that won't be visible to anybody but you, but that is commenting.
Please assume that we would be putting comments in every code block even though I don't take the time to do it throughout this course. So that's the importance of commenting code. If you can get in the habit of doing it right away, you will be much better off in the long term. So PHP comments come in a variety of ways. You can do it up in here in the insert bar, or you can use this comment. This is known as the Coding toolbar. So those are PHP comments.
There are currently no FAQs about Dynamic Dreamweaver Websites: Creating and Validating Forms.