Friday, November 21, 2008

PHP Development Tutorial


Class Hierachies And Overriding

The PHP Object Oriented method of programming brings many exciting possiblities to application code. Many of the theories surrounding PHP Object Oriented code comes from some simple concepts. To the new comer, some of these concepts seem a little abstract, and with good reason. Abstraction is a key concept on Object Oriented code, but to the un-initiated, may seem rather vague.

This tutorial attempts to bring to light, the concept of abstration, class hierachies, and polymorphism. But rather than boggle the mind with pages of theory, lets look at how it works.

Read More

SPL Autoload

The SPL suite of tools contains many useful classes and methods for a variety of tasks. In most applications custom classes are used and included for use with the include or require language constructs. To make this job easier, SPL includes the __autoload function that will automatically load classes when instantiated.

Read More

SQLite-ON DUPLICATE KEY UPDATE

SQLite is an ultra lite database replacement that comes bundled with PHP. Because of its light weight it lacks many of the features found in more robust applications such as MySQL, PostgresQL and others. One of the features that is lacking is the ON DUPLICATE KEY UPDATE that is often used to automatically UPDATE a record, should a duplicate field be found. Here a demonstration is provided to duplicate this behaviour using PHP Exceptions.

Read More

Introduction to SPL DirectoryIterator

The Standard PHP Library (SPL) contains a wide array of classes designed to provide a standard method of traversing aggregate structures with PHP. The DirectoryIterator is one of the more oft used of the Iterator classes and this tutorial helps to expose the user to developing in a standardised and Object Oriented approach.

Read More

Introduction to SPL ArrayAccess

The Standard PHP Library (SPL) offers a great deal of easy to use class and interfaces to bring a standardised method of traversing aggregate structures to PHP code. The ArrayAccess interface implements a method of handling objects as if they were arrays.

Read More

Introduction To SQL

Many PHP websites are database driven with database backends. The language used in relational databases is SQL. Regardless of the database used, a standard language is used to communicate with them all. This tutorial shows some basic concepts to using SQL.

Read More

PHP Security

The ease of entry into PHP coding is without doubt one of its greatest assets. When it comes to security, it is also one of its greatest liablities. New comers to the language can create simple scripts to add to their site with relative ease, however, they do so without any knowledge of security. These same new comers to PHP also copy and paste insecure scripts from examples all over the net, and assume if it from known source, it must be secure. This article looks at several common security issues when developing with PHP and more importantly, how to fix them.

Read More

Preventing Multiple Submits

The problem of multiple form submissions is quite common in PHP. Many people use forms for database interactions and emailing etc, but when the form is submitted, the page can be refreshed and the POST data, or file uploads is POSTed once again. This tutorial brings an easy remedy to the issue with the use of form tokens and sessions.

Read More

Introduction to PHP and MySQL

This tutorial is aimed at those new to PHP and MySQL. The object of this tutorials is to show by way of example how to use php to CREATE a database, how to CREATE a table, how to INSERT data into a database, and how to SELECT that data and display. Each task is accompanied with examples for each of the mysql, mysqli and PDO extensions.

Read More

Introduction to PHP Regex

To the untrained eye, Regular Expressions are meaningless hieroglyphics which can only be deciphered by Egyptian Sun Gods. This tutorial starts with the basics and leads through to more advance regular expression use.

Read More

Creating A PHP Application

This tutorial aims to introduce the new PHP coder to some of the more common PHP functions that are used in application development. The code base creates a PHP Blog, complete with a user system and introduces basic user access and CRUD. The tutorial uses no Object Oriented code in a bid to highlight the use of PHP functions and their usage in real world situations. A complete working download is provided and can be skinned with CSS for those who simply require a blog.

Read More

MySQL Scheduler

The MySQL scheduler is provides a method of assigning tasks for future use, or for recurring uses. The scheduler works much like cron or the windows task scheduler and allows the user to add, edit, view, and delete events from the schedule table.

Read More

Video Conversion With FFMPEG

There are many tools and programs about to convert and to manipulate video for the web. Most of these make use of the freely available ffmpeg library to do the conversions and manipulations.
When used with PHP, the ffmpeg library is typically called using the exec() or system() functions. This provides the fastest method of video conversion without reading the whole video, or multiple video's into memory.

Read More

XML And XSL

Long before templating became fashionable and it was thought a good thing to seperate program logic and display logic XML and XSL were already doing the job effortlessly. The benifits of using XML for data are many with true cross platform extensibility and ease of use. this tutorial begins with the fundamentals of XML and XSL and how PHP brings them together to create a HTML document.

Read More

Tagging With PHP And MySQL

A simple yet flexible tagging solution is provided here which adopts a bookmark type approach to tagging items. Each item is stored in a MySQL database and related to tags. The system has the ability to learn new tags and is fully relational.

Read More

Imagick

Image manipulation with PHP has long been a contencious issue. With the Imagick extension PHP has all the capabilities of ImageMagick and then a little more. This tutorial introduces some basic imaging concepts such as generating thumbnails, watermarking and much more.

Read More

Asynchronous Form Submission With Xajax

This short tutorial describes and shows how to submit a form asynchronoussly using xajax. This allows users to submit a form without a page reload. Ideal for login scripts etc. The tutorial follows on to show how the response form the form can be manipulated by adding effects from the scriptaculous library. The first of these is adding a fade effect to the form response.

Read More

Geo Targetting With PHP And MySQL

Geo targetting and Geo location are big money now in web applications. Companies such as Yahoo and Google offer maps and the ability to put markers on maps with locations of stores or cities within a given radius of a zip code. This tutorial shows how to calculate the latitude and longitude of a zip/post code or the latitude and longitude of stores within a 10 mile radius. These latitude and longitude calculations can then be used to create maps in other applications. The hard number crunching is handled in the database to improve speed as the some of the calculations are complex.

Read More

Dropdown Select With PHP and MySQL

Creating drop down lists for HTML forms can be done in several ways. Options for the drop downs may fetch the values from an array of from database results. This tutorial uses both methods to create a drop down select and adds a function for the creation of a multiple select also.

Read More

Design Patterns

Many people are familiar with a few design patterns used with PHP. MVC and singleton patterns proliferate applicatios to create a coding frameworks for PHP applications. This tutorial introduces some of the most common design patterns used in PHP, and some lesser known patterns that can help produce enterprise level applications.

Read More

Introduction To Arrays

This tutorial introduces the new comer to the concept of PHP arrays. With examples showing how to create, delete and add to arrays and various methods for looping over them. There are over 70 different array functions in the PHP manual and this tutorial introduces some of the base concepts to get started with this useful tool.

Read More

Run Script From Cron

As an addition to tutorials that make use of PHP from the command line, this mini tutorial covers an introduction to cron and crontab. With step by step instructions and examples, the mystery of cron be be yours to master. Also included is a cron creation tool for those who fear vi.

Read More

Introduction To eZ Components part 3

This third part in the eZ Components series describes how to create an RSS feed with the eZ Components Feed Component.This tutorial also introduces the database component and together show the required steps to connecting to a dabase, fetching results, and using the result set to generate an RSS Feed.

Read More

Model View Controller MVC

This tutorial takes the user step by step through the process of building a MVC Framework with PHP. It covers Model View Controller and templating. Each step is accompanied by example source code and the the finished MVC Framework is also available for download

Read More

Pagination with PHP and PDO

Pagination of database results is one of the tasks that a PHP developer will be required to carry out many times. This tutorial takes the coder through each step of building a pagination menu and paginating through a database result set using PDO

Read More

Creating Dropdowns with PHP and Xajax

This tutorial shows how to create dynamic dropdown select menus using PHP Xajax and MySQL. Data is fetched from the database and the menu updated asynchronisly using just PHP and Xajax with no javascript.

Read More

Basic Login Authentication with PHP and MySQL

Many tutorials have been written that cover this subject. Few however, cover any matter of securing forms or the database queries. This tutorial provides the basics to get you started with PHP and MySQL authentication with example code to guide you throug

Read More

Introduction To eZ Components part 2

This second article in the eZ Components series focuses on the use of UserInput and Mail Components and creates a simple and secure web based contact form.

Read More

Introduction To eZ Components part 1

eZ Components is a component library for Rapid Application Development with PHP. eZ Components reduces the need for writing excessive code by implementing a wide array of ready built solutions for a customer-centric enterprise.

Read More

Managing Hierarchical Data with PHP and MySQL

Tradionally the way to handle hierarchical data has been with XML. Here we expand on previous works to show how you can manage hierarchical data with PHP and MySQL.

Read More

Filtering Data with PHP

With security at the forefront of PHP programming, it is left to individual developers to make sure thier applications are not vulnerable to attack. The Filter extension provides a set of tools for data validation and sanitizing.

Read More

Introduction to SPL

A formidible introduction to the Standard PHP LIbrary. This tutorial brings the power of PHPs Object Oriented approach to iterators and data serialization. Iterators have been described as Simple in a complex way. But with a few basic concepts the vast pe

Read More

PHP Coding Style

Over the years of development of the PHP many programmers have come to inflict their own coding styles on thier scripts. There are almost as many coding styles as their are languages, but which is the right one for PHP?

Read More

PHP Type Casting

PHP is a loosely typed, or dynamically typed language. In a strongly typed programming language, you have to declare (define) the type and name of the variable before using it. PHP by-passes this step allowing direct declarations of variable and then sets

Read More

Storing Images in MySQL with PHP

Often regarded as a Bad Idea (tm) the storing of binary data has been a contensious issue for many years and many religious wars have been fought over it. Here we dispell some of the myths and show how to do it the Right Way(tm)

Read More

Object Oriented Programming with PHP

With the latest PHP Object Oriented Progamming techniques scripts can be created quickly and efficiently with reusable code. This tutorial guides you through some basic concepts of OOP with PHP.

Read More

PHP-Exceptions

With the advent of PHP 5 came the new OO model and a new Object Oriented approach of dealing with errors. Exceptions give us much better handling of errors an allow us to customize the behavior of our scripts when an error (Exception) is encountered

Read More

Introduction to PHP PDO

The myriad variaty of databases available now it has become quite a task to keep up with them all syntactically. To this end PDO provides a common interface to all databases supported by PHP.

Read More

Validating User Input

I have lost count of the amount of times I have seen code like include ($_GET[filename]. Some people do not seem to be getting the message. This article is an attempt to show how input from web based forms can be dealt with safely.

Read More

Introduction To PHP Sessions

PHP Sessions are an excellent tool for securely passing data from one page to another, or for global access to variables across pages. This tutorial steps through the many different uses of sessions and some bizarre ones also.

Read More

Introduction to PHP templating

We have all seen web sites that keep a nice tidy menu bar and header and have the
content change when a link is clicked. How do they change only the content
and keep the rest of the site the same. This effect is a basic form of templating with

Read More