This PHP Tutorial shows the user how to set environment varialbles and how to retrieve environment variables using PHP. Also shown is how to include different configuration files based on the environment.
This is a short tutorial to show how to display the table comments and field comments for a MySQL table.
In this tutorial a single page website is created using AngularJS and Bootstrap with pages that load without a browser refresh.
In this tutorial several supporting technologies are used to extract data from a PHP api, using PHP PDO extension, and creating a JSON array from the result set. The JSON data is then consumed by AngularJS for display.
Ensuring referential integrity of data is something that slips by many developers who are designing their own database. With the advent of data driven services, the integrity of the data that is served to applications is paramount to the success of the application, and the businesses that use them.
This tutorial introduces the user to the concept of MySQL FULLTEXT searching and ordering results by relevancy.
This tutorial introduces the recursiveDirectoryIterator iterator and shows its workings along with the recursiveIteratorIterator iterator and shows how to filter the recursiveDirectoryIterator iterator with the filterIterator
This tutorial introduces the concept of Database Normalization for database tables, covering First Normal Form (1NF), Second Normal Form (2NF) and Third Normal Form (3NF).
There is a lot of confusion surrounding PHP Lamdas, Anonymous Functions and Closures. What are they? How do they work? How do I handle errors? etc. This tutorial breaks down the complexity of Closures and Anonymous Functions and lays them bare in a simple manner.
Automated testing of web pages has been made even easier with the release of Selenium2. The PHPUnit test suite has kept pace with Selenium2 development and has integrated automated selenium tests into the already expansive toolkit.
This tutorial introduces the Subversion, or SVN, versioning system for users of PHP and any other language or project. SVN is a free and open source version control system. SVN provides the ability to manages files and directories, and the changes made to them, over time
This tutorial demonstrates the installation of MongoDB, the installation of the MongoDB extension, and provides examples of a basic CRUD using PHP and ongoDB.
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
This tutorial demonstrates how PHP can make use of traits to provide a solution when multiple inheritance is required. PHP, like Java, does not support multiple inheritance, however, with the use of PHP traits, the same behaviour can be created
Quite often when coding with PHP, there is a need to insert many items into a a database. The data may come from a feed, an array in yousr code, a form submitting multiple values or many other sources. This tutorial looks at optimizing this process by using a single query to insert multiple records
This is a light weight introduction to some basic concepts in Mecurial versioning. Adding a repository, branching with mecurial, commiting etc.
There are possibly as many menu systems available for PHP and MySQL as there are PHP programmers. Here is yet another way of generating menus from a database.
There are possibly as many menu systems available for PHP and MySQL as there are PHP programmers. Here is yet another way of generating menus from a database.
PHPRO.ORG 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.
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.
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.
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.
In the previous tutorial, Introduction to Xajax the basic concepts of using xajax were layed out in simple procedural code. This tutorial takes the next step in development and shows, by way of example, how xajax can be utilized in an Object Oriented environment.
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.
This tutorial demonstrates the flexibilty of PDO by making use of the PHPRO CRUD class found at http://www.phpro.org/classes/PDO-CRUD.html. The CRUD class provides an example of how the build in PDO class can be used to provide cross database support whilst using the same standard interface. The examples provide and easy to use guide to several databases and show how the CRUD API works.
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.
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.
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.
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.
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.
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.
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.
This example is an extension of the Create Thumbnail With GD example from earlier. This example provides auto detection of image type, resizing with aspect ratio, and variables for control of thumbnail size and quality. A great start to writing your own image gallery or anywhere you need ana image thumbnail.
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.
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.
PHP contains a robust feature set of error handling mechanisms such as E_WARNING, E_STRICT, E_ALL etc. Often these errors pop up unexpectedly at run time and should be handled correctly. This function provides a method of handling runtime errors as exceptions.
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.
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.
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.
Recently, a PHPRO.ORG user requested a database of all the Counties in the UK. Not towns or cities, just the Counties. This database dump provides a table of all Counties in the UK. Ideal for dropdown menus or any other use.
This example shows how to create a simple finger client with php. The script connects to kernel.org to fetch the latest linux kernel information. Here a simple unordered list is created to display the contents. Handy for displaying the latest kernel updates on you website
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.
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.
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.
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.
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.
The heat in the internet advertising just got turned up to eleven as Microsoft finally put pay to the resistance of Yahoo and settled on a price reported to be 62 Billion Dollars (USD). This is not a merger, this is a hostile take over, but what to the pundits think? Will Google respond with predatory pricing?
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.
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.
Here is a handy function for those messing with goe location and geo targetting or other geo graphical toys. This function convert degrees to radians for use in map plotting etc.
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
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.
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.
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.
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.
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
This article shows the use of two methods of highlighting seach text using PHP. A comparison is included using strings and regex for achieving this. This functionality used on many sites to show search words to make easier navigation for the user.
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
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?
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
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.
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.
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.
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.
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?
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
This class utilizes the coolness of PDO to produce HTML forms based on the fields of a database. Because PDO is a universal database access layer this class can generate forms from any database supported by PDO
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)
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.
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
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.
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.
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
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.
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.
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.
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