QRdvark Tutorials

Creating Graphs With PHP MySQL-D3JS

Creating graphs and charts with javascript has led to greater development of libraries capable of creating them. Most often, these graphs and charts will be data driven with data from external sources, most commonly a database. This tutorial provides a working example of creating an area chart with D3.js, PHP and MySQL.

Concatination And Compressing Files With Grunt

With the advent of more and more Javascript being used to enhance user experience, tools have evolved to deal with the increased number of requests made on a server and the size of the javascript files served. The Grunt suite of tools allows for easy concatination and compression of files to ease load on servers and make development easier by breaking up Javascript files into units of work.

Creating Threaded Comments With PHP And Postgresql Recursive Query

In a previous tutorial the use of MPPT nested sets has been well covered, however, data does not always come to in such a ready format, also, MPTT runs down the path of Naive Trees. Often times we are confronted with an Adjacency list style of data which merely provides a parent ID. This tutorials shows how this method of storage can be used to good effect with the use of PostgreSQL CTEs and PHP

Anonymous Classes With PHP

With the advent of PHP 5.3, Anonymous functions were introduced. Some felt there was still work to be done in this space, and with the advent of PHP 7, Anonymous Classes were introduced. This tutorial explores the concept of Anonymous Classes with PHP and how they can be used.

Introduction To GIT

A quick and easy introduction to the GIT distributed version control and source code management (SCM) system. This tutorial provides easy examples to get you started with you own GIT repository, or if you simply want to download and use a remote repository

nWire Eclipse Zend Plugin Review

QRdvark.com receives many emails requesting reviews for magazines, web sites, application development tools, applications, books etc. Now and again, one of these catches the eye and deserves further inspection. Recently, a request for a product called nWire arrived which allegedly "accelerates PHP development by helping developers navigate through their code and better understand the architecture of their application". Here is a closer look at nWire.

Dynamically Create Menu With PHP DOM

Programatically createing menus using php is a task many programmers will need to do over and over again in developing applications and web sites. Most PHP coders will have their own menu generation class that will take an array or an item and add it to a HTML un-ordered list or other tag and the styling is handled with CSS. This has proven to be a worthy solution to menu creation, however, PHP already has all the tools and classes built in to create a menu using DOM. It is both powerful and extensible and further eliminates for yet another class in your tree.

Introduction To SimpleXML With PHP

XML creation and manipulation can be quite complex and so, PHP has provided several methods of handling XML. Each method has a varying degree of complexity, but perhaps the simplest of them all, is the approriately named extension, SimpleXML This tutorial requires a fundamental understanding of XML structures. If you lack this, it is highly recommended brushing up on XML and how it can be used.

Introduction To PostgreSQL

This tutorial introduces the user to the postresql database and how to interface with it. The system used for this demonstration is CentOS but mostly the information is generic to any distribution or operating system. Before launching into using PHP to interface with PostgreSQL, this tutorial aims to introduce the user to some simple operations on getting a postgreSQL database installed, creating a database, and performing basic CRUD (Create Retreive Update Delete) operations. It is hoped that a PHP user with a grounding in the basics will better understand what PHP is doing when using pg_* suite of functions, or, for the more evolved, using PDO as an interface.

SPL AppendIterator

The SPL AppendIterator provides a method of iterating over multiple arrays at the same time. This can be very useful when aggregating data from different sources, such as XML or RSS feeds or even multiple database sources. The flexibility and efficiency of the whole SPL suite of tools is a the disposal of the AppendIterator making manipulating data in multiple objects fast and simple with a minimum of code.

Introduction To Xajax

The Xajax library provides a useful and simple method of generating asynchronous requests with next to not knowledge of javascript. All the javascript code is generated internally and leaves the developer to simply implement PHP functions. This tutorials is an absolute basic beginners guide to getting started with xajax. Full source code is provided with an explaination of how the process works.

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.

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.


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.

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.

Easter Egg

The life of a PHP core developers can be unsatisfying. Constantly striving to fit in many hours of unpaid development to bring the world a better product. It is little wonder that sometimes, a mischivious deed breaks the tediom. Easter Eggs are nothng new in programming, and PHP joins the rest with own version.

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.

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.

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.

Recursive File Exists

The PHP file_exists() function provides a method of checking if a file exists at a given path. This function extends this functionality to check if a file exists anywhere within a provided directory recursively. This means the file may be within any sub directory also and still be found.

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.

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.


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.


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.

Days Between Two Dates

This function provides a simple and effective method of counting the number of days between two dates. An option is also provided to return partial days also. This function does not calculate years or months or seconds, only days. Ideal for countdown scripts and the like.

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.

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.

Get Riemann Distance

This function will calculate the distance between two points on the earth using the great circle distance formulae. This function should not be used to calculate linear distances, instead use the GetLinearDistance function. This function will return a value in miles, nautical miles or kilometers

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.

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.

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.


Why is it developers and organisations choosing PHP over .NET. The .NET platform has some redeeming features yet is constantly beaten in the numbers game when compared to PHP. Is it just a trend or is PHP set to stay the course?

When you need to get the size of an entire directory using PHP this function will give you result in Bytes. You can then do the math to format it into KB or MB or whatever format you like.

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


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

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. An additional section has been added for the inclusion of useful tips when working with MySQL. The tips include random queries for often requested operations that many PHP users put into their PHP code where it properly belongs in the database.