Getting started with PHP
If you want to learn the basics of PHP, then you've come to the right place. The goal of this series is to teach you everything you need to know about PHP so that you can:
- Create and design your own PHP project
- Understand and customize PHP scripts found on the net
- Become the ultimate PHP guru
What is PHP? Well, to quote php.net, the home of PHP, it is this: "PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML." Permalink for this article http://mirror.magicode.org/content/Getting_started_with_PHP
The keyword is embedded, meaning you can start off with HTML and jump in and out of PHP mode at will, simply by encapsulating the PHP code by <?php and ?>. This text was originally written for http://blog.magicode.org
For instance, this PHP code:
<?php echo "Hello world"; ?>
is equal to the following HTML code:
Hello world
and will output the same.
If you see this notice on any site other than magicode.org, it's probably been lifted without consent
The difference between PHP from something like Javascript is that the code is executed on the server before the result is sent to the browser, or the shell if you're using PHP in CLI-modus. The client will receive the result of the script, but won't know the underlying code.
PHP is easy to start with, and has a lot to offer advanced programmers, making it the ideal language for writing web applications.
What can PHP do for you?
Your imagination is the limit (and your skills, but that will come with practice). PHP can help you create a web site, from the tiniest blog to the largest application you can think of (think Yahoo!, and you get the picture).
What you should know
- You need to know the basic syntax of HTML, especially the basic tags and forms.
- General programming knowledge. Not required, but it makes thing easier. Don't sweat it if you don't have it, it's easy to learn.
Installing PHP
You can download PHP and get complete installation instructions from this location. If you're on windows, I would advise you to take a look at a package called WAMP-server, which let you install PHP as well as MySQL (a popular database solution) and Apache (the world's most popular web server) with a few clicks. If you're on Linux, it's simply a matter of installing each component by itself from the core depository of the distribution you're using.
Overview
From now on, I will assume that you have PHP set up and running, either locally on your computer, or on a hosted or dedicated server setup at an ISP.This series is aimed at the beginners, but will gradually take the step up to the expert programming, with advanced tips for the power user. If you already know a lot, you may consider going directly to the advanced section
In any case, you should not aim to plow through the entire tutorial in one sitting. Read a few lessons, try things out, and take a break, and then return when the information has had time to sink in. Happy hacking :)
