• 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 / Articles tagged: php

php

PHP Anonymous Functions: What Are They, and Why Use Them?

10 December 2012 / 8 Comments

PHP Anonymous Functions: What Are They, and Why Use Them?

In this tutorial you’ll explore anonymous functions in PHP. Anonymous functions are a PHP feature that you probably won’t use that often; however, they can be really useful in certain situations, as you’ll see.

You’ll look at the following concepts in this tutorial:

  • What anonymous functions are, and how you create them
  • How to assign anonymous functions to variables
  • How to call anonymous functions
  • Using anonymous functions to create neater callbacks, and
  • Creating closures with anonymous functions.

Ready to dive into anonymous functions in PHP? Let’s go!

[Read more…] about PHP Anonymous Functions: What Are They, and Why Use Them?

How to Add Image Uploading to Your CMS

31 May 2012 / 93 Comments

How to Add Image Uploading to Your CMS

View Demo » | Download Code

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

In my tutorial Build a CMS in an Afternoon with PHP and MySQL, I showed how to build a simple but useful content management system with PHP and MySQL. I also showed how to extend the CMS to allow article categories.

In this tutorial, you’ll look at another way to extend the CMS. You’ll take the original CMS code, and modify it so that the administrator can upload an image for each article. Then, when a visitor views an article page, the CMS will display the image at the start of the article. In addition, our CMS will generate a smaller thumbnail version of each article image, and display this thumbnail next to each article headline in the homepage and article archive pages.

You can see the finished result by clicking the View Demo link above. Notice the thumbnail images next to each article headline. Click a headline or thumbnail to view the corresponding article, along with the full-size article image.

[Read more…] about How to Add Image Uploading to Your CMS

Easy HTML Templates with Mustache

27 April 2012 / 13 Comments

Easy HTML Templates with Mustache

Templates are a great way to separate your website’s code from its design. There are many great web template systems available for different languages and platforms, including Smarty for PHP and the Django template language for Python.

In this tutorial you’ll explore Mustache, a relatively new and very simple template system that you can easily use to create HTML templates. You’ll look at various topics, including:

  • The advantages of using Mustache
  • How to install and use the Mustache processor
  • How Mustache tags, variables, and data objects work
  • Using sections to create conditions and loops
  • Including one Mustache template inside another
  • …and lots more!

Along the way, you’ll see plenty of code examples that show you how Mustache works. At the end of the tutorial, there’s a complete example that uses Mustache, along with jQuery, to create a simple Ajax-based product list page.

[Read more…] about Easy HTML Templates with Mustache

How to Add Article Categories to Your CMS

25 January 2012 / 68 Comments

How to Add Article Categories to Your CMS

View Demo » | Download Code

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

Since publishing my tutorial Build a CMS in an Afternoon with PHP and MySQL, many readers have asked how to add more features to the CMS. I thought I’d answer some of these questions by writing additional tutorials that build on the original simple CMS.

In this tutorial, you’ll learn how to add article categories to the CMS. Categories give your site more flexibility: as well as listing all articles on the homepage, you can create separate section pages of your site, with each section page listing the articles belonging to a particular category.

For example, our original CMS demo lumps all types of article — news, reviews, and interviews — together on both the homepage and the archive page. By creating separate News, Reviews, and Interviews article categories in our CMS, we can then create individual archive pages for news, reviews, and interviews in our site.

You can see how this looks by clicking the View Demo link above. Notice that each article title on the homepage has a category name below it (Interviews, Reviews or News). Click a category to view its archive page, which lists all articles in that category, along with the description of the category at the top of the page.

[Read more…] about How to Add Article Categories to Your CMS

Object-Oriented PHP: Autoloading, Serializing, and Querying Objects

29 June 2011 / 9 Comments

Object-Oriented PHP: Autoloading, Serializing, and Querying Objects

Welcome to my fourth object-oriented PHP tutorial! If you missed the first three then you may want to take a look at those first, to give yourself a thorough grounding in PHP classes and objects:

  • Object-Oriented PHP for Absolute Beginners
  • Delving Deeper into Properties and Methods
  • Working with Inheritance

If you’ve read all the articles up to this point then you’re already familiar with the most important concepts of object-oriented programming in PHP: classes, objects, properties, methods, and inheritance. In this final (for now, at least!) tutorial in the series, I’m going to tie up some loose ends and look at some other useful OOP-related features of PHP:

  • How to automatically load classes on demand
  • Converting objects to and from strings for easy storage and transmission, and
  • Useful ways to find out more about a given class or object.

Ready? Let’s go!

[Read more…] about Object-Oriented PHP: Autoloading, Serializing, and Querying Objects

Object-Oriented PHP: Working with Inheritance

26 May 2011 / 2 Comments

Object-Oriented PHP: Working with Inheritance

Welcome to my third object-oriented PHP tutorial! If you haven’t already checked out the first two then you may want to take a look at those first, since this tutorial builds on the previous two:

  • Object-Oriented PHP for Absolute Beginners
  • Delving Deeper into Properties and Methods

In this article we’re going to explore the idea of inheritance in object-oriented programming, and how inheritance works in PHP. With inheritance, your objects and classes can become much more powerful and flexible, and you can save a lot of time and effort with your coding.

We’ll look at the following topics in this article:

  • The concept of inheritance, and why it’s so useful
  • How one PHP class can inherit from another
  • How a child class can override some of the functionality of its parent
  • Working with final classes and methods
  • Using abstract classes, and
  • Working with interfaces.

Ready? Let’s get started!

[Read more…] about Object-Oriented PHP: Working with Inheritance

Object-Oriented PHP for Absolute Beginners

8 April 2011 / 10 Comments

Object-Oriented PHP for Absolute Beginners

Welcome to the first in a series of tutorials covering object-oriented programming in PHP. In this series you’ll explore the various ideas and concepts involved in object-oriented programming, and learn how to build robust object-oriented PHP applications quickly and easily.

In this tutorial, we’re going to kick things off nice and gently by looking at some really basic concepts of object-oriented programming. You’re going to learn:

  • What object-oriented programming is
  • How object-oriented programming can help you write better PHP scripts
  • Some fundamental concepts, including classes, objects, methods and properties, and
  • How to start writing object-oriented PHP code.

Ready to explore the world of PHP objects? Let’s get started!

[Read more…] about Object-Oriented PHP for Absolute Beginners

How to Make a Slick Ajax Contact Form with jQuery and PHP

1 April 2011 / 299 Comments

How to Make a Slick Ajax Contact Form with jQuery and PHP

View Demo »

Download Code

Contact forms can be useful way for visitors to contact the owner of a site. They’re easy to use, and since they don’t expose the site owner’s email address in the page, they cut down on spam too.

However, contact forms can also be cumbersome, especially as they’re usually on a separate page. The visitor has to visit the contact form page, fill in the details, view yet another response page, and then try to make their way back to the page they were originally reading.

Fortunately, Ajax gives us a way round this problem. By embedding the form in the page, and submitting the form data via Ajax, the user never has to leave the current page. It also provides a smoother experience for the user.

In this tutorial we’ll build a nice-looking, embedded Ajax contact form that the user can summon up by clicking a link in the page. Along the way, we’ll explore various topics, including:

  • HTML5 form fields
  • How to use fallback techniques to make the form function even if the browser has JavaScript turned off
  • Using CSS techniques to create attractive forms
  • Writing a secure form mailer using PHP
  • Animating page elements with jQuery, and, of course…
  • Using jQuery to make Ajax requests

Before you begin, check out the finished product by clicking the View Demo button above. This opens a new page with some dummy content, and a couple of “Send us an email” links. Click one of these links to display the form.

The demo doesn’t actually send an email anywhere, but the finished code in the download is fully functional. To get the code, click the Download Code button above.

Ready? Let’s get started!

[Read more…] about How to Make a Slick Ajax Contact Form with jQuery and PHP

JSON Basics: What You Need to Know

24 March 2011 / 13 Comments

JSON Basics: What You Need to Know

If you’ve developed websites or web apps at all, you’ve probably heard of JSON, at least in passing. But what exactly is JSON? What can it do, and how do you use it?

In this tutorial you’ll learn the basics of JSON. You’ll look at the following topics:

  • What JSON does
  • The kinds of things JSON is used for
  • How to create JSON strings
  • A simple JSON example
  • How JSON compares to XML, and
  • How to work with JSON using both JavaScript and PHP.

Let’s get started!

[Read more…] about JSON Basics: What You Need to Know

PHP Recursive Functions: How to Write Them, and Why They’re Useful

4 February 2011 / 9 Comments

PHP Recursive Functions: How to Write Them, and Why They're Useful

Like most programming languages that support functions, PHP lets you write recursive functions. In this tutorial, we’ll explore the concept of recursion in PHP, and discover how to create recursive functions for various tasks.

Recursion is one of those topics that can seem confusing at first, but once you start writing recursive functions you’ll see how elegant recursion can be!

[Read more…] about PHP Recursive Functions: How to Write Them, and Why They’re Useful

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • 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