Learning PHP: Setting Up an Environment

19 Feb

When I started writing these tutorials, I completely omitted the fact that you’ll need a web server running PHP to see the result of the code I’ve been providing. My bad!

Fortunately there’s a dead simple way to get going without any real knowledge of servers or hosting packages. Let’s get started.

First we’re going to head over to¬†download WAMPServer. The download should start shortly.

WAMP Download Screen Shot

It’s a farily large download, so it may take a few minutes for you to get the installer downloaded.

The installer doesn’t require any input from you while you’re installing it so simply click through the different steps of the installer until it begins installing the software, and then just let it do its thing.

WAMP Installer Running

The installer will ask you if you want to use a different browser than Internet Explorer this is up to you. If you select yes, you will have to point it to the browser you want it to use as the default. If you select no, it will use Internet Explorer as the default browser. The same will be asked of you for notepad. You can select NO for both options as they are not really important.

Now you should have WAMP server installed. You can click start and run WAMPServer. You should see an icon in the lower right hand corner of your screen like the screen shot below.

Finally we can test that our server is up and running by visiting LocalHost at (http://localhost). You should be presented with the page below.

Now we are going to go into our WAMP www folder and empty it out.


Remove everything in this folder. From now on, any PHP file we create, we will save in this directory. Once saved there, you can access the file by visiting http://localhost/NameOfFile.php

I’ve copied our lessons into my www folder and now if I visit http://localhost/Lesson2.php I can now see the result of our PHP Math.


As always if things don’t go as planned or you have any questions, please leave a comment and we will get you sorted out!

Until next time!

Learning PHP: Some Basic Math

19 Feb

Welcome back!

The next step we’re going to take with PHP is to get it performing some basic math operations for us. PHP easily makes short work of even the most complicated math work, but you need to know how to write it.

The example below will step you through the basic operations in math.

Try them out for yourself and see how you get on!


// First we are going to set up some variables with values.

$value1 = 10;
$value2 = 5;

// Now we're going to explain the various ways we can do math.

// Multiplication Example: 10 X 5 is done in PHP using the asterisk *

$multiplication = $value1 * $value2; // 10 x 5

// Addition is done using the plus sign

$addition = $value1 + $value2; // 10 + 5

// Division is done using a forward slash

$division = $value1 / $value2; // 10 / 5

// Subtraction is done using a hyphen

$subtraction = $value1 - $value2; // 10 - 5

// Brackets

// We can also use brackets in our math.

$brackets = ($value1 + $value2) + ($value1 - $value2); // (15) + (5)

// Now we can print out our results

echo $multiplication;

echo '<br /><br />'; // This is used to add a couple of line breaks so that the output doesn't run into itself. Try removing these and see what happens

echo $addition;

echo '<br /><br />'; // This is used to add a couple of line breaks so that the output doesn't run into itself. Try removing these and see what happens

echo $division;

echo '<br /><br />'; // This is used to add a couple of line breaks so that the output doesn't run into itself. Try removing these and see what happens

echo $subtraction;

echo '<br /><br />'; // This is used to add a couple of line breaks so that the output doesn't run into itself. Try removing these and see what happens

echo $brackets; // This is the last line so no need to add the breaks.

If you have any questions, please leave a comment below and I’ll get you sorted out!

Learning PHP: The Intro

18 Feb

Hello and welcome to my little PHP tutorials. These posts are meant to help people learn and understand how to use PHP. I feel like a lot of people think that coding is complicated and hard to learn but if they only knew just how simple it can be, more people would give it a try. These posts are not going to drone on about useless stuff that you can read in the PHP Documentation, but will be simple, practicle examples that you can use. Let’s get started, shall we?

Creating a PHP File

PHP files can be created using something as simple as notepad or as advanced as PHP Storm. Depending on your budget, find a tool that’s suitable for you to write code in. Here are some free software suites to make writing code a bit easier:

Personally I’m partial to NetBeans but that’s only because that is what I got started on.

Here are the steps to create your very first PHP file using nothing more than Notepad::

  1. Open notepad.
  2. Write your opening PHP tag
  3. Write some hello world code.
  4. Close your PHP tag.
  5. Click file -> Save As.
  6. Name your file. Don’t forget to add the .php at the end of the file name.
  7. In the drop down called “Save as type” select all files.
  8. Select where you’d like to save the file.
  9. Click save.

Once these steps are completed, you’ve written your very first batch of PHP which should look something like the code below.

<?php //This is the open PHP tag.

//This is the hello world code
echo 'Hello World.';

//This is the close PHP tag


Next on the agenda, we will make PHP do some basic math. Catch you on the next post how bow dah?

How I Got Into Coding

16 Jan

A lot of people have asked me about how I got into coding and I don’t think I’ve ever told the story before on this little blog of mine.

Growing up I was really into skateboarding and to be honest I never really even looked at a computer. That’s when I met Chris Panagapko. Chris was the one to get me stoked on computers and learning all kinds of really cool shit!

Chris and I used to play a lot of Counter-Strike together and we decided to try and get a server up and off the ground. Chris at that time already knew quite a bit about VMware Workstation and so we set up a Windows server and installed the Counter-Strike dedicated server software on it. Chris was one of those lucky few who had a static IP at home, so we were able to run the server out of his parents basement.

We spent a lot of time in that basement messing with servers and virtualization. It was a lot of fun for a couple of nerdy kids growing up. Eventually we started a Counter-Strike clan aptly named cNc (ChrisNet Clan) which was appropriate at that time but now just makes me laugh! It was a lot of fun and again I learned some awesome shit because of it.

We wanted a web site for the clan so Chris introduced me to Microsoft Frontpage to get the job done. I remember spending hours and hours messing around with code and looking at the live preview pane hoping what I had done would work. I started to learn the basics of HTML and CSS and once I had mastered that, I really wanted to learn how to process data through a web site.

Enter PHP

I had toyed around with a lot of different premade PHP systems like E107, PHPBB, and eventually WordPress, but I wanted to write custom software. Stuff for a purpose that I could define and then write code for.

I found PHP to be one of the easiest languages to pick up because the syntax is super simple and it is very fault tolerant. It just worked for me.

Eventually I made it up in my head that this is what I wanted to do with my life. Create applications for people to use on the web. I invested a lot of time away from friends and parties to learn how to do this sort of stuff, then I went to college to learn all the fundamentals that you don’t really get when you learn on your own (or maybe some people do?).

In the end I owe my entire beginnings and career to Chris. He was someone who loved this stuff and simply shared a small chunk of his passion with me. That’s how I got into coding.

WordPress “Designers”

17 Sep

wordpress-logo-simplified-rgbThere’s something I’ve really been getting sick of lately and that is WordPress “Designers” who say that something can’t be done when in fact it can be done and is quite simple.

Quite a few of these so called designers are simply people who take an existing wordpress theme, and use the Customizer to make it look the way their client wants. They do not actually go through the motions of designing a WordPress theme.

I had a client ask me about making the thumbnails on her archives page square and not distorting the images by resizing them to 180 x 180. This is fairly simple to do however their “designer” told them it was not possible. So for that “designer”, I’ve provided a code sample as to how I did it.

printf( '<div style="height:180px; width:180px;background:url('.$image.');background-size:cover;"></div>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );

This creates a div using the post image as the background image and makes the div 180 x 180. Using the background-size cover means the image will be draped over the div and not constrained to it. The result is exactly what the client asked for and took about 10 minutes to perfect.

So if you’re a “designer” you may want to learn how HTML and CSS work so that you can actually help your customers and not just take their money.

Next Up for NimbleNotebook

14 May

This weekend will be another weekend filled with coding methinks.

I have a lot of things I want to try out with NimbleNotebook.com

Upcoming additions:

  • Edit your user profile and add an avatar.
  • Images with notes. Add one or more images to a note.
  • New note types. Tutorial note that allows your note to have steps and images for each step.
  • Note encryption. Encrypt a note with your own key so only you can see it.

Lots of fun stuff to work on.