Here is the first of tutorials that I will make to cover the basics of PHP. My goal is not to have yet another tutorial-blog/site, but to show how I got started with PHP and eventually show some advanced things you can do with it. To reach that goal, I first want to introduce ‘newbies’ to PHP. In this tutorial I’m going to assume you have basic knowledge of HTML, which will be used sometimes in examples. If you don’t know HTML, I recommend visiting w3schools.com
What is PHP?
PHP is a scripting language which is used among others for creating dynamic web pages.
What does PHP stand for?
PHP stands for: Hypertext Preprocessor. You might ask me what the first P stands for… well, back in the days PHP used to mean: Personal Home Page, but then they wanted something more sophisticated and changed it a little while keeping the first P.
What can you do with it?
There infinitely many things you could do with PHP, but it comes down to this list of general subjects:
- create dynamic web page
- create web application
- PhpMyAdmin (database management system)
- create a CMS(content management system)
- create <script_name_here>
A nice example of a dynamic web page is this very Blog, written by the WordPress community volunteers in PHP. It’s simply a dynamic web page, with a back-end that allows login that provides access to a content management system designed to create a Blog or add pages, the wonderful thing about WordPress is that you can very easily use Plugins also written in PHP.
What do you need to get started?
To start using PHP on Windows, I recommend the following programs:
- Apache webserver
- PHP 5.3.0
You can download what is called a WAMP/LAMP stack. It’s a package that contains:
The W or L stands for Windows or Linux. So for the Windows users lets download my favorite WAMP stack: WampServer. After downloading follow these steps to install it:
So now that you have WampServer2, your ready to write your first PHP code!
First PHP code
If you left the default installation path, open up an explorer and go to C:/wamp/www/. Now create a new folder, I will call mine “firstPHP”. Now you should go into this folder: C:/wamp/www/firstPHP/. Fire up your favorite browser (you probably already did, because you are reading this text!). Open a new tab and goto: http://localhost
If all went well, you should now see this page:
Now that everything is setup right, lets finally write our first PHP code! Open up a notepad and write the following HTML code which contains a piece of PHP and save it as index.php in your firstPHP folder:
<html> <head> <title>My First PHP</title> </head> <body> <?php echo "My First Php! Hello World is Lame!"; ?> </body> </html>
After saving it, goto http://localhost/firstPHP/ and you should see this:
In this tutorial you have learned:
- What PHP stands for
- How to install WampServer2
- How to write your first PHP code