So you’ve decided that you want to learn a new language and PHP is your language of choice. Now that you’ve made your decision, I’m going to walk you through how to get PHP running on your system and how to begin learning a new language.
So You’ve Chosen Your Language
Learning a new language can be a little bit intimidating and frustrating at times. You have to remember that it’s not always going to be this hard. Once you start to get a feel for the language everything will start to become easier and you will begin to learn quicker.
The Internet is a great place to find information, but i’ve always found having a physical book in front of you will help you immensely because you can flip back and forth between pages and examples with ease.
There are 100′s of PHP books that have been published and probably 100′s more in the works. If you search amazon you will probably find a book to suite your needs, but here are a couple i’ve found useful.
Both are published by O’Reilly Media, Inc. which coincidently have been the publisher of choice for programming books i’ve purchased.
MAMP: Getting a Local Server Up and Running
PHP is a server side script so we are going to need a server to run our scripts. If you already have a web server setup somewhere, then you can skip this step and start writing code right now. If you don’t, we are going to download a program called MAMP whcih will allow us to run PHP scripts right from your Mac.
Head on over to the MAMP website and download the latest version of MAMP. You don’t need MAMP Pro, so just stick with the regular version, plus it’s free!
Once you have MAMP installed double click the app to get it launched. Right out of the box, we are up and running, but lets customize it a bit to fit your needs.

Click on the Apache tab and you’ll notice that there is only 1 option to choose. This is basically the path to the root of your MAMP server. I have mine set to /Work/Sites. You can set it to whatever makes it easiest for you.
If you decide to leave this option alone the folder is located in /Applications/MAMP/htdocs
If the server isn’t already running, go ahead and click Start Servers to get everything started.
Errors, Errors, ERRORS!
Error reporting is going to be your guardian angel when getting started, and working, with PHP. All server configurations are different so placing this piece of code at the top of your PHP script will make sure that the server will spit out any errors.
error_reporting(E_ALL);
ini_set("display_errors", 1);
include("file_with_errors.php");
By default, MAMP has error reporting turned off, so to be safe we are going to turn it on.
1. Find your ‘MAMP’ directory in ‘Applications’
2. Find ‘conf’ and open it up..
3. Open up php4 or php5 (depending on your enabled version)
4. Line 270 should be something like this:
error_reporting = E_ALL5. Line 277 will be:
display_errors = OffChange this to:
display_errors = On6. Restart servers
And voila! We have PHP errors..
The above tip is not my own work. Copyright does not belong to me, it belongs to Jamie Huskisson. So thank them!
Choosing An Editor
This is all personal preference. You could argue with developers till you’re blue in the face over the pros and cons of various text editors. The top 3 in my mind are:
You can choose any of the 3 above or go with your personal favorite but it’s important to choose an editor with decent syntax highlighting. This will just be one more step in finding errors because lets face it, you’ll be making a lot of errors. I’ve been coding for 4 years and I make more errors than anyone I know ![]()
How’s Your Environment?
As I said before, learning a new language can be frustrating so make sure you setup an learning environment that is calming. Depending on how you work this could be 1000 different options.
Personally, I like to sit in an empty room and listen to music as loud as humanly possible. You’re just trying to make sure you are extremely focused so find your environment and try to stick with that.
Getting Your Hands Dirty
There is only so much theory a person can handle before they need to start coding some examples. Every book, website, teacher i’ve encountered always has examples of scripts to provide. I’ve found that simply copy and pasting the examples and getting them to work isn’t exactly the best practice.
Rewrite the examples
Always re-write the examples as you go along. Every line. Try not to copy and paste. Rewriting all the code will help engrave it into your brain and will help you understand why that line of code needs to be there and what it does.
Leave yourself notes
Comment as you work. If you complete a difficult section, write a little bit of what just happened. Again, this will help you understand what’s going on and it will help leave a lasting impression in your mind.
Don’t stop until the example is complete
If you’re going to start an example, make sure you leave yourself enough time to make sure it’s working properly. Even if you’re about to throw your computer out the window, sit back, take a break and try and tackle it again. It’ll be 10x harder to come back the next day, find where you are, see what you’ve done and continue.
Ask Questions
The great thing about the internet is if you’ve encountered a problem, some else has and has usually found a solution to it.
Joining a forum will allow you to get real feedback instead of having to read an article someone wrote. One of the forums i’ve frequented since I started coding with PHP was PHP Freaks, but there are 100′s of development forums out there. Try and find a good community and join in.
If you’re going to join a forum, make sure to search around in older threads to see if there is a solution to your problem. Forum go’ers aren’t usually the most friendly people when people are asking the same questions over and over. Just make sure when you are asking a question to provide source code of what you’re working on and a little write up of what you think is causing the problem and be patient. If you’re answer isn’t answered within 15 minutes, don’t get discouraged. Just be patient!
Another thing you can do is try to help out other people with their problems. This will help with debugging scripts in the future and if you run into a problem you may remember that you’ve helped someone else fix that problem in the past.
Dive In Head First
Now that you’ve got some reading material, your server is all setup and you’re in a relaxing, learning positive environment it’s time to start learning. Remember to have fun and don’t get frustrated!
As a little gift, here is a little PHP tutorial.
//lets display some text on the screen echo 'Thanks for reading my article, I hope you enjoyed it!';
Background provided by David Lanham




