PHP Basics / Code Basics pt. 1
Subtitles of the Movie
In this lesson we're going to begin to learn PHP. The PHP documents I create I'm going to save at the root level of the web server documents folder. In Mac OS 10, that's at the MacIntosh hard drive library web server and documents. Inside this documents folder I'm going to create a folder for each chapter in our tutorial. Since this is Chapter 2, I've created a folder for 0201 and that's where I'm going to save the document that we'll be creating right now. I've also made a shortcut to the documents folder down on the dock and I'm displaying the documents folder in list view on the right-hand side to take up less room so I have more room for my code editor and my web browser. Let's open up our code editor and create a new document. I'm going to place some simple HTML in this document and then save it inside the 0201 folder, calling it 0201.php. Remember, we need to name it with the .php extension so that it gets passed to the PHP engine for processing. Now that I've saved it, let's look at it in the web browser. Here's my simple HTML output, which contains no output in the browser window. But if I look at the source code, I can see my HTML document. Let's go ahead and put some text in here just so that we have something to look at. Now let's go ahead and put some PHP code in here. We do this by declaring where our PHP code begins with the PHP declaration, which is a less than sign, question mark and then PHP. At this point, the PHP processor is going to start processing code all the way down until it reads a termination statement. The termination statement is a question mark and the greater than sign. This right here encloses the PHP code for processing. Anytime the PHP engine sees these declarations, it begins to process PHP code until it reaches the termination declaration. After this, it ignores everything else unless it sees the PHP declaration sign again. I could have PHP code interwoven throughout my HTML document, including down at the very end. This is one of the beauties of PHP when working with websites because you can interweave your PHP code and logic and output, conditionally outputting many times blocks of HTML. You can use PHP to conditionally output forms, the contents of forms, even CSS and graphics. Let's backup now to our first PHP declaration. I'm going to type just some innocuous text in here just to see what happens. When I refresh this in the browser, I get an error. PHP will give you errors when it doesn't understand what you're trying to type. It can be very annoying at times, but the fact is PHP does a pretty good job of telling you when and where mistakes occurred. It says that I have a mistake on line five. Actually, my mistake is on line three. The reason that it thinks it's on line five is because it keeps going through all the way until PHP reaches a termination or another statement that it understands. It doesn't really understand text. And it keeps going until it gets to the termination statement, which it does understand and then it says, oh, I didn't understand anything that I just read throughout these lines and I just found that out when I got to line five. This is important to know when you're troubleshooting PHP because oftentimes you'll see that the error line that it tells you is not exactly where the error actually is. Oftentimes it's a line or two before. This is a good point to pause. We'll continue on with our lesson in the next movie.
Tutorial Information
| Course: | FileMaker 9 & PHP Foundations |
| Author: | Lance Hallberg |
| SKU: | 33786 |
| ISBN: | 1-933736-99-2 |
| Release Date: | 2007-08-22 |
| Duration: | 9.5 hrs / 107 lessons |
| Work Files: |
Yes |
| Captions: | For Online University members only |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |
VTC Sign up & Benefits
- Unlimited Access
- 81,350 Video Tutorials (20,800 free)
- Video Available as Flash or QuickTime
- Over 782 Courses
- $30 for One Month Access
- Multi-User Discounts Available
United States 