• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Matt Doyle | Elated Communications

Web and WordPress Development

  • About Me
  • Blog
    • Design & Multimedia
      • Photoshop
      • Paint Shop Pro
      • Video & Audio
    • Online Marketing
      • E-Commerce
      • Social Media
    • Running a Website
      • WordPress
      • Apache
      • UNIX and Linux
      • Using FTP
    • Web Development
      • HTML
      • CSS
      • JavaScript
      • PHP
      • Perl and CGI Scripting
  • Portfolio
  • Contact Me
  • Hire Me
Home / Blog / Web Development / PHP

PHP

Explore PHP, one of the most popular Web programming languages in use today. Learn how PHP works and how to write useful PHP scripts and applications.

See also:
  • PHP Strings
  • PHP Arrays
  • PHP Functions
  • PHP Objects

Build a CMS in an Afternoon with PHP and MySQL

21 January 2011 / 622 Comments

Build a CMS in an Afternoon with PHP and MySQL

View Demo » | Download Code

14 May 2019: This article and the code were updated for PHP7 compatibility.

Building a content management system can seem like a daunting task to the novice PHP developer. However, it needn’t be that difficult. In this tutorial I’ll show you how to build a basic, but fully functional, CMS from scratch in just a few hours. Yes, it can be done!

Along the way, you’ll learn how to create MySQL databases and tables; how to work with PHP objects, constants, includes, sessions, and other features; how to separate business logic from presentation; how to make your PHP code more secure, and much more!

[Read more…] about Build a CMS in an Afternoon with PHP and MySQL

PHP References: How They Work, and When to Use Them

19 November 2010 / 18 Comments

PHP References: How They Work, and When to Use Them

References are a very useful part of PHP and, for that matter, most other programming languages. However, references can be somewhat confusing when you first start learning about them.

This tutorial is a gentle introduction to references in PHP. You find out what references are, and how they work. You learn how to create and delete references, as well as pass references to and from functions. You also explore some other uses of references, and discover situations where PHP creates references automatically on your behalf.

[Read more…] about PHP References: How They Work, and When to Use Them

PHP Variable Scope: All You Need to Know

15 October 2010 / 6 Comments

PHP Variable Scope: All You Need to Know

When you’re just starting to work with functions and objects in PHP, variable scope can be the cause of some confusion. Fortunately, PHP’s scope rules are relatively easy to understand (compared to some other languages, at least!).

In this tutorial you’ll learn all you need to know about variable scope in PHP. You’ll look at:

  • The concept of variable scope — what it is, and what it means
  • The differences between global and local scope
  • How to access global variables from within a function
  • PHP’s superglobals, and how they work
  • How to use static variables to preserve state

Let’s get started!

[Read more…] about PHP Variable Scope: All You Need to Know

Make Your Own PHP Functions: The Newbie Guide

16 September 2010 / 4 Comments

Make Your Own PHP Functions: The Newbie Guide

You’re no doubt familiar with using functions in PHP. The language contains hundreds of built-in functions that you can use for all sorts of handy jobs — from manipulating text through to reading files, sending email messages and processing images.

You’re not limited to using just the predefined functions, though — you can create your own functions too! In this tutorial, I’ll show you how. You’ll learn:

  • Why it’s good to create your own functions
  • How to create and use a function
  • How to make your functions flexible by using parameters
  • All about optional parameters and default values, and
  • How to return values from your functions.

Ready? Let’s get started!

[Read more…] about Make Your Own PHP Functions: The Newbie Guide

Easy Ways to Sort Arrays in PHP

16 August 2010 / 2 Comments

Easy Ways to Sort Arrays in PHP

As I mentioned in my earlier article, Creating Arrays in PHP, arrays are very useful if you need to store and manipulate a large amount of data in one go. One useful way you can manipulate this data is to sort it in a particular order.

PHP gives you a large number of sorting functions that can sort arrays using many different criteria. For example, you can sort in ascending or descending order, by key, or by value. These functions make it really easy to sort arrays without getting bogged down in the details of sort algorithms.

We won’t try to cover every single PHP array-sorting function in this tutorial. Instead, you’ll learn about the functions that you’re likely to find the most useful in your everyday coding.

Let’s get started!

[Read more…] about Easy Ways to Sort Arrays in PHP

Using Multidimensional Arrays in PHP

19 July 2010 / 16 Comments

Using Multidimensional Arrays in PHP

Array elements in PHP can hold values of any type, such as numbers, strings and objects. They can also hold other arrays, which means you can create multidimensional, or nested, arrays.

In this tutorial you learn how to create multidimensional arrays, how to access elements in a multidimensional array, and how to loop through multidimensional arrays.

[Read more…] about Using Multidimensional Arrays in PHP

Using foreach to Loop Through PHP Arrays

27 May 2010 / 2 Comments

Using foreach to Loop Through PHP Arrays

Often you need to move through all the elements in a PHP array so that you can do something with each element’s value. For example, you may want to display each value in an HTML table, or give each element a new value.

In Counting PHP Array Elements Using count(), I showed how you can use a for loop along with the count() function to loop through an array. However, there’s a much easier way to loop through arrays: the foreach construct.

In this article you learn the basic syntax of foreach, and see how to use it to loop through both indexed and associative arrays.

[Read more…] about Using foreach to Loop Through PHP Arrays

Counting PHP Array Elements Using count()

6 May 2010 / Leave a Comment

Counting PHP Array Elements Using count()

Often it’s useful to know how many elements an array contains. Here are some common reasons for counting the number of elements in an array:

  • You can then use a for loop to move through the elements
  • You can display the total number of elements to the user (such as the number of search results returned)
  • You can calculate the average of the values in the array (in conjunction with array_sum())

PHP makes it easy to count array elements, thanks to its built-in count() function. In this tutorial you’ll learn how to use count() to count the elements in both regular and multidimensional arrays, and how to move through all the elements of an indexed array by using count() and a for loop.

[Read more…] about Counting PHP Array Elements Using count()

Extracting Elements from PHP Arrays with array_slice()

30 March 2010 / Leave a Comment

In Working With Array Elements in PHP, you saw how to read and change individual elements within a PHP array. However, sometimes it’s useful to work with a range of array elements. For example, you may want to work with a large array in chunks, or sort an array then retrieve just the “top 10” values from the start of the array.

In this tutorial you’ll explore PHP’s array_slice() function for extracting a range of elements from an array.

[Read more…] about Extracting Elements from PHP Arrays with array_slice()

Working With Array Elements in PHP

19 March 2010 / 2 Comments

In Creating Arrays in PHP, you learned how PHP arrays work, and saw how to create an array using PHP.

In this article you take things further, and look at how to access the individual elements inside a PHP array. You’ll see how to:

  • Read element values
  • Alter element values
  • Add and remove elements in an array
  • Output the entire contents of an array

[Read more…] about Working With Array Elements in PHP

  • « Go to Previous Page
  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to page 4
  • Go to page 5
  • Go to Next Page »

Primary Sidebar

Hire Matt!

Matt Doyle headshot

Need a little help with your website? I have over 20 years of web development experience under my belt. Let’s chat!

Matt Doyle - Codeable Expert Certificate

Hire Me Today

Call Me: +61 2 8006 0622

Stay in Touch!

Subscribe to get a quick email whenever I add new articles, free goodies, or special offers. I won’t spam you.

Subscribe

Recent Posts

  • Make a Rotatable 3D Product Boxshot with Three.js
  • Speed Up Your WordPress Website: 11 Simple Steps to a Faster Site
  • Reboot!
  • Wordfence Tutorial: How to Keep Your WordPress Site Safe from Hackers
  • How to Make Awesome-Looking Images for Your Website

Footer

Contact Matt

  • Email Me
  • Call Me: +61 2 8006 0622

Follow Matt

  • E-mail
  • Facebook
  • GitHub
  • LinkedIn
  • Twitter

Copyright © 1996-2023 Elated Communications. All rights reserved.
Affiliate Disclaimer | Privacy Policy | Terms of Use | Service T&C | Credits