Monday, October 18, 2010

PHP Basics: Your first script/web page

The first and main reason why I like PHP so much is because of its flexibility. There is no need to define, cast, convert variable types all the time. PHP does it for you automatically which makes it so easy to work with.


To continue the following basic tutorial you have to make sure PHP is installed on your machine along with virtual host. Personally, I use EasyPHP. One file, one installation and everything is up and running. Also, make sure you're familiar with basic HTML syntax.


Step 1: Create a file page_one.php in your www folder (or wherever your working localhost directory is).


Step 2: Copy this code from text area into your file and save.



Step 3: Launch the file in your browser. The output you will get is:

My first page


< ?php ?> - These are opening and closing tags for the browser to identify where PHP syntax begins and ends.
echo - Echo statement is used to print information on the page.

No comments:

Post a Comment