In order to use PHP you will need three things:
- Webserver (or webhost) with PHP installed
- A text editor
- A web browser
- Optional: a database, such as MySQL
We’ll begin with getting in to PHP, so open up your text editor and enter the following (don’t copy and paste, you’ll learn slower!)
Your PHP code should always start and end with the above code. Although PHP has other tags that can be used such as <% %> (ASP tags) and ?> (these are short tags), the ASP tags will not be working as of PHP6, and some people feel that the short tags are bad practice.
Ok back to the tutorial! Sometimes while you’re coding, you might want to leave yourself a note or two. You can accomplish this with comments. PHP has three types of comments, as displayed below.
<?php # The first comment type is a hash comment # anything after the hash, on the same line # will be ignored by PHP. // the second type is the double forward slash comment // anything after the double slashes, on the same line // will be ignored by PHP /* The third type is the multi-line comment anything between the opener: / * (no space) and the closer: * / (again, no space) will be ignored by PHP */ ?>
And there you have it, some basic syntax to help you with your PHP development!
Hope to see you in the next tutorial.