Mark’s Site

Pensieve for coding and golf :-)

Getting Started

By admin • Apr 16th, 2008 • Category: 1.1. Where to Start with PHP

PHP is a programming language written specifically for (but not limited to) web applications. It can be downloaded free from http://www.php.net/downloads.php, with different versions available depending on the hardware (server) you have available. Eg. Windows (’yay’), Mac (’boo’), Linux (’meh’) etc. If you are fearful of installations and want some guidance, just type ‘install php windows’ into Google and you’ll find plenty of articles that can help you. Or better yet, look at the official manual, as it has sections detailing installation for the various platforms.

The Facts You Need To Know

Introductions

PHP used to stand for Personal Home Page, but now stands for PHP: Hypertext Preprocessor. Yes PHP is in the acronym, it’s recursion at its worst :-) To stop myself from repeating that which has already been written well by others, I will simply guide you towards the officlal online manual for PHP below and get you thinking with a simple example.

Online Manual

PHP has a great online manual here to help you get your groundings. As a general rule, to test if you have PHP installed successfully, create a new file and add this for the contents:

<?php
echo phpinfo();
?>

Save the file on your webserver where you have installed PHP and run the file. If successful, you will see an output of PHP information related to your installation, telling you the version of PHP you are running, and what is turned on/off in your installation. If you see some kind of error, or nothing at all, then Google is your friend. If you are still having troubles and PHP has not installed successfully and you need to think seriously about whether you can really handle such a complicated task. Maybe you were destined to be one of those simple-minded Mac people that can’t handle a real PC ;-)

Hello World

After reading through a few sections of the manual and having gone through the PHP installation, I’m sure you’ll be able to write your first script, because you’ll know that PHP code is surrounded by <?php and ?> tags and that to output text, you either use the functions ‘echo’ or ‘print’.

Writing a Hello World script is important so you know the basics of outputting text in PHP, as text output is a large part of web programming. Once you’ve mastered text output, you can start using variables, methods and logic to display different information under different circumstances. Don’t stress, all of those things will be explained shortly.

Your Task

  1. Your first task is to output the words ‘Hello World’ using entirely PHP (no html). Have fun :-)
  2. Your second task is to output those same words using PHP and HTML (by surrounding those words in HTML paragraph tags)

Any problems, Google is your best friend.

admin is
Email this author | All posts by admin

Leave a Reply