|
www.BYOGeek.com Where you can learn to Be Your Own Geek! |
| |
home
php tutorials:byogeek tutorialsbyogeek referenceFree Resources![]() ![]() |
breaking it down - php tagsOk so following on with our last lesson, we'll take a closer look at some of this wierd new code we used. Let's look at the first line:
<?php
If you followed my html tutorials, you would have learned about "tags" which tell the browser what to do. In php lesson 1 you should have also learned the the difference between client side and server side. Php is processed by the server, but we still use our browser(client) to access and view the results so the first thing we need to do when writing php code is to tell the browser that php is going to be running the show by using an opening php tag "<?php". Lazy coders also simply use the tag "<?" as the opening tag but it's a good habit to use the full tag. Now if we skip all the code we wrote after that tag and we go to the bottom of our php script, we also have a closing tag:
?>
Now our browser knows that everything between those two tags is programming code or "script" which is to be processed by php on the server. Anything typed outside of those two tags is treated by the browser as html by default. One other thing you may have noticed with your first program is that we saved it as "happy_sad_what.php" instead of "happy_sad_what.html". This tells the browser that the document is a php document. You can type html code in a php document and will be processed as html but if you type php code in a html document, it won't be treated as php even with the the php tags. Now if we look at the rest of our php script in between those two tags, you'll notice that there are no more tags, instead have a series of lines which look a little wierd. In the next lesson, we'll break it down a bit more and take at closer look at some of that code and learn about variables. Click here to continue to php lesson 5. Lesson added Friday 28th July 2009 |
things to do list:
|
© 2008-2009 BYOGeek.com / nesperion.net | ||