5 Minute How To: Get Started Programming with PHP

PHP is one of the most popular web programming languages used today. You’ll find millions of web pages written using PHP which stands for PHP: Hypertext Preprocessor (originally an acronym for Personal Home Page). I’ve had an interest in web development for some time and now that I’m getting into it for real, I’ve found that PHP is both easy to learn and very powerful as well as being free (open source).

PHP is what’s called a server-side scripting language. What this means is that PHP scripts are executed on the web server rather than being downloaded to your browser to run. Javascript is an example of a client-side scripting language that runs after being downloaded to your browser. What gets served up to your browser from a PHP script is just html or xhtml and any client-side script you may include in it.

The first thing necessary in learning PHP is an environment where PHP can run. You can purchase web hosting from a host that supports PHP, like Bluehost.com. If you’d like to run the code on your own computer without getting an account, download WAMP or MAMP. These are free web development packages for Windows and Mac respectively that will run an Apache web server with PHP and MySQL installed. MySQL is an open source database that’s often paired with PHP websites.

Follow the instructions to either set up your web hosting or install your development environment. After this, you’re ready to begin programming. Since this is a 5 minute how to, we’ll only have a couple of minutes to create a simple web page that includes PHP. Don’t be disappointed; there will be more how to’s that delve into the topic in more depth.

So, open a the text editor of your choice, making sure it saves files in plain text format, not rich text, and type the following:


<html>
<head>
<title>My first web page with PHP!</title>
</head>
<body>
< ?php
echo 'Hello World!'
?>
</body>
</html>

That’s it. Save the file as ‘index.php’ in your web folder. If your using MAMP, the web folder will be /MAMP/htdocs/. On a web server, it might be a folder named public-html. Again, if you’re using MAMP, run the program to turn on the web server and navigate in your browser window to ‘http://localhost:8888/index.php’. Your page should come up and display the words ‘Hello World!’

This was a very basic intro to PHP programming. For more information, check out these books from Amazon:

Beginning PHP and MySQL 5: From Novice to Professional, Second Edition
PHP and MySQL Web Development (3rd Edition) (Developer’s Library)

or these free web resources:

phpfreaks
php.net

Related posts:

  1. Five Minute How To Series
  2. 5 Minute How To: Drive More Traffic to Your Site
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

15 Responses to 5 Minute How To: Get Started Programming with PHP

  1. Pingback: Wordpress Plugin to Format Code Samples at FreshBlogger

  2. Sandra says:

    Thanks so much for the info and the links. I’ve been wanting to learn about PHP and feel so behind the times because they didn’t include it at all with the course I took.

  3. ray says:

    Hi Sandra. I’m really glad you found the article useful. I’d like to dig into the PHP topic a little more deeply, but haven’t had the time lately. Someday, though. Thanks for visiting and leaving a comment and good luck with your blog!

  4. I been really wondering about PHP and I’ve been learning about it bit by bit. this is a great resource and It’s helped me learn a couple of new things about PHP. I been wanting to use it for a while now and I’m still not ready yet but you have helped me answer a few question that I was unsure of!

  5. ray says:

    Thanks, James. I’m still fairly new to PHP, but I’d like to learn a lot more. It really helps to know it these days if you’re into blogging or internet marketing…

  6. Komik says:

    Thanks for the brief introduction. I know fairly good amount of PHP, and I highly recommend getting into a paid PHP course. Some tips and tricks you learn at the course really helps you to get out of the “newb” phase.

  7. ray says:

    Hey Komik. It’s my pleasure. If I get more deeply into the programming side of things on the web, I may do that. Being in programming for my day job, I’m used to just picking things up as I go along whenever I need to learn something new. Lots of people could probably benefit from taking a class. Thanks for visiting!

  8. praveen says:

    Learning Php is very useful, since most of the Poweful blogs like wordpress, type pad and various powerful scripts are almost coded in PHP and Mysql. Even most of themes are coded in wordpress.

  9. praveen says:

    above was a typo mistake in the last sentence, Most wordpress themes are coded in Php and Mysql

  10. Roma says:

    If you would like to run php on localhost there’s also xampp

  11. Thank you so much Ray!
    I couldnt agree more with Sandra. Remember those early times when people forgot their mother tongue and spoke in C and C#…. now with PHP in town, it feels like history is repeating itself with a new kid on the block.

    Thanks again…you made it sound all so easy, I’m beginning to feel its not a monster thats catching up on my age :-)

  12. Hi Ray

    I have come to this post late, but like a number of other peoples comments share an interest in php and of course you have to start somewhere.

    many Thanks for this post

    Kind Regards

    Chris

  13. ray says:

    Hi Chris,
    I’m glad to have you as a reader and I really appreciate your comments. It’s really useful to have at least a basic knowledge of PHP and HTML for people who are interested in making money on the web. Thanks for visiting and I hope to see you around here again soon.

  14. David says:

    Thanks for this. With php becoming more and more of a standard in websites nowadays, a guide like this really helps to understand what all the fuss is about, and how I can actually achieve getting a foothold in the PHP side of websites; thanks.

  15. For any WordPress blogger, some knowledge of PHP is must. Whether it is configuring plugins or modifying themes knowledge of PHP is a life saver.

    Php.net is the resource I regularly use. The user comments on it are pretty useful.