Home of all things tech!
Posts tagged web design
PHP – Fun with Functions
Aug 7th
Hopefully you are pretty secure with the basics of PHP by now. If not, you should read part 1 and part 2 of this series. This part is about functions. What are they; how do you use them; and how can you utilise your own functions? Functions can be a great tool to speed up your coding and to make applications run much more smoothly, so let’s go!
What are functions?
Functions are blocks of code that can be called upon at any point in the script to perform a particular task or ‘function’. There are more than 750 functions built into a normal install of PHP, but you can define your own too, making them very versatile and easy. More >
PHP – Your Next Steps
Jul 31st
Assuming you have read my basic introduction to PHP, you should have a fair understanding of what PHP is, how to write it, and how to assign and manipulate strings and numbers. In this tutorial, I will be teaching you about Arrays, Loops, and ‘if… else…’ statements. So, let’s get started.
Arrays
Say you had a big long list of related variables that you needed to store. For example, names of people. You could store them in separate strings, as you learned before, like this:
<?php $name1 = "Matt"; $name2 = "Harry"; $name3 = "Bill"; $name4 = "John"; ?>
However, doing this makes it difficult for them to interact with each other and makes looping through them all tricky. These problems can be solved by using an array. An array uses ‘keys’ to link the strings together in one variable. There are three types of array: numeric, associative, and multidimensional. I’ll leave out multidimensional arrays for now, and focus on numeric and associative as these are more common and easier to use. I will use a numeric array in this example, as there is only one factor linking the variables, the fact that they are all names. More >
PHP – The Basics
Jul 24th

PHP Logo
PHP has grown from nothing to become one of the most popular languages on the web. This is mainly because of it’s simple syntax, easy usage, and seamless integration with MySQL and other databases. It’s also free, which makes it a great tool for developers when designing interactive and
dynamic content. In fact, my blog is powered by the open-source software WordPress.org, which is written in PHP.
What is this ‘PHP’ thing?
You may be thinking “wow, it sounds great, but what is it?”. So here are a few points about PHP:
- PHP stands for PHP: Hypertext Preprocessor (It’s a bit of a paradoxical name if you ask me!)
- PHP is a server-side scripting language, which means the scripts are executed on the server – before the user sees any output. (This is similar to ASP.net)
- The opposite of server-side is client-side. JavaScript is a client-side scripting language.
- Although PHP is free and open source, you need a server to run PHP, you can’t just access it in your browser. Common servers include Apache and Microsoft’s IIS.
- PHP files have the extension .php / .php3 / .phtml
What do I need?
To be honest, you don’t really need much at all! A simple text editor such as NotePad or TextEdit will suffice. I use NotePad++ for various reasons, outlined in my review, but mainly because of it’s syntax highlighting. You could also try NotePad2 for a more lightweight option.
Also, as I mentioned earlier, you need a webserver to parse the script. This means you will need to host your files somewhere. This could be locally, using a package such as XAMPP, or you could buy hosting, but make sure they offer PHP support. (Most hosts will, as PHP is free and open source.)
Got all that? Good, let’s start writing some code! More >
Using OO-PHP To Connect To A Database
Jul 20th
With OO-PHP, you can dramatically speed up the coding process, and re-use code much more effectively. OO-PHP stands for Object Oriented PHP. This means it uses objects, which are collections of properties and methods, rather that a bunch of variables and functions.
Also, as the object is stored in an external file, it can be accessed from any of your pages and used anywhere on your site. This makes objects especially useful. A good example of this is using an object to connect to and interact with a database. In this example, I will use MySQL; but the beauty of objects is that you can change that one file and all the pages will be updated, which makes changing between databases easy! More >